Skip to content

tests

Modules

test_card_file_load

Functions

all_datatypes
all_datatypes()
Source code in tests/test_card_file_load.py
14
15
16
@pytest.fixture
def all_datatypes():
    return _load_file("all_datatypes.card")
config
config()
Source code in tests/test_card_file_load.py
54
55
56
@pytest.fixture
def config():
    return _load_file("config.card.r7417")
dynamico
dynamico()
Source code in tests/test_card_file_load.py
120
121
122
@pytest.fixture
def dynamico():
    return _load_file("dynamico.card.r7417")
lmdz
lmdz()
Source code in tests/test_card_file_load.py
193
194
195
@pytest.fixture
def lmdz():
    return _load_file("lmdz.card.r7417")
orchidee
orchidee()
Source code in tests/test_card_file_load.py
345
346
347
@pytest.fixture
def orchidee():
    return _load_file("orchidee.card.r7417")
test_card
test_card()
Source code in tests/test_card_file_load.py
565
566
567
@pytest.fixture
def test_card():
    return _load_file("TestFile.card")
test_load_all_datatypes
test_load_all_datatypes(all_datatypes)
Source code in tests/test_card_file_load.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
def test_load_all_datatypes(all_datatypes):
    assert all_datatypes == {
        "empty_section": {},
        "logical": {
            "y1": True,
            "y2": True,
            "y3": True,
            "y4": True,
            "n1": False,
            "n2": False,
            "n3": False,
            "n4": False,
        },
        "list": {
            "l1": [],
            "l2": [[], []],
            "l3": [[], [], []],
            "l4": [1],
            "l5": [[], [1]],
            "l6": [[], [1], []],
            "l7": [1, True, False, "text", '"text2"'],
            "l8": ["${SUBMIT_DIR}/PARAM/XIOS/iodef.xml", "."],
        },
        "date": {"begin": "2024-06-01", "end": "2024-06-30"},
        "path": {
            "file1": "${SUBMIT_DIR}/../${year}/some_file.ext",
            "file2": '"${SUBMIT_DIR}/../${year}/some_file.ext"',
            "file3": ".",
        },
        "empty": {"e1": None, "e2": None},
        "empty_section2": {},
        "string": {"n1": "NONE", "n2": "OFF"},
    }
test_load_config
test_load_config(config)
Source code in tests/test_card_file_load.py
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
def test_load_config(config):
    assert config == {
        "Compatibility": {"libIGCM": 1.0},
        "UserChoices": {
            "JobName": "CREATE-AMIP.01",
            "LongName": '"create_etat0_limit for interannuel amip run"',
            "TagName": "ICOLMDZOR",
            "SpaceName": "DEVT",
            "ExperimentName": "CE0L",
            "ExpType": "ICOLMDZOR/LAM/CREATE_amip",
            "CalendarType": "leap",
            "DateBegin": "2000-06-01",
            "DateEnd": "2000-06-05",
            "PeriodLength": "5D",
            "CompressionLevel": 2,
            "EnvFile": "${SUBMIT_DIR}/../ARCH/arch.env",
            "OptMode": "prod",
        },
        "ListOfComponents": {
            "ICO": ["dynamico", "DYNAMICO"],
            "ATM": ["lmdz", "LMDZ6"],
            "IOS": ["xios", "XIOS3"],
        },
        "Executable": {
            "ICO": ["icosa_lmdz_orch22_${OptMode}.exe", "icosa_lmdz.exe", "640MPI"],
            "ATM": ['""', '""'],
            "IOS": ["xios_server_${OptMode}.exe", "xios.x", "2MPI"],
        },
        "Restarts": {
            "OverRule": False,
            "RestartDate": None,
            "RestartJobName": None,
            "RestartPath": None,
        },
        "ICO": {
            "Restart": False,
            "RestartDate": None,
            "RestartJobName": None,
            "RestartPath": None,
        },
        "ATM": {
            "Restart": False,
            "RestartDate": None,
            "RestartJobName": None,
            "RestartPath": None,
        },
        "IOS": {
            "Restart": False,
            "RestartDate": None,
            "RestartJobName": None,
            "RestartPath": None,
        },
        "Post": {
            "MetricsPCMDI": False,
            "PackFrequency": "NONE",
            "SeasonalFrequency": "NONE",
            "TimeSeriesFrequency": "NONE",
        },
    }
test_load_dynamico
test_load_dynamico(dynamico)
Source code in tests/test_card_file_load.py
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
def test_load_dynamico(dynamico):
    assert dynamico == {
        "Compatibility": {"libIGCM": 1.0},
        "UserChoices": {
            "RESOL_NBP": 80,
            "RESOL_ATM_Z": 79,
            "etat0": "database",
            "create_etat0_limit": True,
            "iflag_phys": 1,
        },
        "InitialStateFiles": {"List": []},
        "BoundaryFiles": {"List": [], "ListNonDel": []},
        "SmoothFiles": {"List": []},
        "ParametersFiles": {
            "List": [
                ["${SUBMIT_DIR}/PARAM/DYNAMICO/earth_const.def", "."],
                [
                    "${SUBMIT_DIR}/PARAM/DYNAMICO/LAM/run_dynamico_global_France.def",
                    "run_dynamico.def",
                ],
                [
                    "${MODIPSL}/modeles/DYNAMICO/xml/DYNAMICO_XML/sponge_dynamico.xml",
                    ".",
                ],
                [
                    "${MODIPSL}/modeles/DYNAMICO/xml/DYNAMICO_XML/context_dynamico.xml",
                    ".",
                ],
                [
                    "${MODIPSL}/modeles/DYNAMICO/xml/DYNAMICO_XML/context_input_dynamico.xml",
                    ".",
                ],
                [
                    "${MODIPSL}/modeles/DYNAMICO/xml/DYNAMICO_XML/field_def_dynamico.xml",
                    ".",
                ],
                ["${MODIPSL}/modeles/ICOSA_LMDZ/xml/XML_XIOS3/param_gw.xml", "."],
                [
                    "${MODIPSL}/modeles/DYNAMICO/xml/DYNAMICO_XML/file_def_dynamico.xml",
                    ".",
                ],
            ]
        },
        "RestartFiles": {"List": ["NONE"]},
        "OutputText": {
            "List": [
                "run_dynamico.def",
                "earth_const.def",
                "iodef.xml",
                "context_dynamico.xml",
                "context_input_dynamico.xml",
                "field_def_dynamico.xml",
                "file_def_dynamico.xml",
                "out_icosa_lmdz.exe.out*",
                "out_icosa_lmdz.exe.err*",
                "xios_client_*",
            ]
        },
        "OutputFiles": {
            "List": [
                "start0.nc",
                "${R_OUT_ICO_O}/Restart/${config_UserChoices_JobName}_${year}_start.nc",
                "NONE",
            ]
        },
    }
test_load_lmdz
test_load_lmdz(lmdz)
Source code in tests/test_card_file_load.py
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
def test_load_lmdz(lmdz):
    assert lmdz == {
        "Compatibility": {"libIGCM": 1.0},
        "UserChoices": {
            "LMDZ_Physics": "NPv6.2",
            "flag_aerosol": 0,
            "ok_ade": False,
            "ok_aie": False,
            "aerosol_couple": False,
            "read_climoz": 0,
            "ok_cdnc": False,
            "flag_aerosol_strat": 0,
        },
        "InitialStateFiles": {"List": []},
        "BoundaryFiles": {
            "List": [
                [
                    "${R_IN}/ATM/LIMIT/AMIP.v20180427/original/360x180.v2/BCS/amipbc_sst_360x180_${year}.nc",
                    "amipbc_sst_1x1.nc",
                ],
                [
                    "${R_IN}/ATM/LIMIT/AMIP.v20180427/original/360x180.v2/BCS/amipbc_sic_360x180_${year}.nc",
                    "amipbc_sic_1x1.nc",
                ],
                [
                    "${R_IN}/ATM/OZONE/UReading/historical.v20160711.v2/original/144x96x66/tro3_${year}.nc",
                    "climoz.nc",
                ],
            ],
            "ListNonDel": [
                ["${R_IN}/ATM/INPUT_CE0L/Albedo4_deg.nc", "Albedo.nc"],
                ["${R_IN}/ATM/INPUT_CE0L/ECDYN4.nc", "ECDYN.nc"],
                ["${R_IN}/ATM/INPUT_CE0L/ECDYN4.nc", "ECPHY.nc"],
                [
                    "${R_IN}/ATM/INPUT_CE0L/Relief_GMTED2010_15n015_00625deg_plus_GA.nc",
                    "Relief.nc",
                ],
                ["${R_IN}/ATM/INPUT_CE0L/landiceref_GA_HR.new.nc", "landiceref.nc"],
                ["${R_IN}/ATM/INPUT_CE0L/Rugos4_deg.nc", "Rugos.nc"],
                [
                    "${R_IN}/ATM/INPUT_CE0L/OROGRAPHY/orography_nbp${RESOL_NBP}.nc",
                    "orography.nc",
                ],
                [
                    "${R_IN}/ATM/START/LAND_WATER_FRACTION/land_water_0.25.nc",
                    "land_water.nc",
                ],
                [
                    "${MODIPSL}/modeles/LMDZ/DefLists/context_lmdz_xios3.xml",
                    "context_lmdz.xml",
                ],
                [
                    "${MODIPSL}/modeles/LMDZ/DefLists/context_input_lmdz_xios3.xml",
                    "context_input_lmdz.xml",
                ],
                ["${MODIPSL}/modeles/LMDZ/DefLists/field_def_lmdz.xml", "."],
                ["${MODIPSL}/modeles/LMDZ/DefLists/field_def_cosp1.xml", "."],
                ["${MODIPSL}/modeles/LMDZ/DefLists/file_def_histmth_lmdz.xml", "."],
                ["${MODIPSL}/modeles/LMDZ/DefLists/file_def_histmthCOSP_lmdz.xml", "."],
                ["${MODIPSL}/modeles/LMDZ/DefLists/file_def_histmthNMC_lmdz.xml", "."],
                ["${MODIPSL}/modeles/LMDZ/DefLists/file_def_histday_lmdz.xml", "."],
                ["${MODIPSL}/modeles/LMDZ/DefLists/file_def_histdayCOSP_lmdz.xml", "."],
                ["${MODIPSL}/modeles/LMDZ/DefLists/file_def_histdayNMC_lmdz.xml", "."],
                ["${MODIPSL}/modeles/LMDZ/DefLists/file_def_histhf_lmdz.xml", "."],
                ["${MODIPSL}/modeles/LMDZ/DefLists/file_def_histhfCOSP_lmdz.xml", "."],
                ["${MODIPSL}/modeles/LMDZ/DefLists/file_def_histhfNMC_lmdz.xml", "."],
                ["${MODIPSL}/modeles/LMDZ/DefLists/file_def_histstn_lmdz.xml", "."],
                ["${MODIPSL}/modeles/LMDZ/DefLists/file_def_histins_lmdz.xml", "."],
                [
                    "${MODIPSL}/modeles/LMDZ/DefLists/file_def_histstrataer_lmdz.xml",
                    ".",
                ],
                [
                    "${MODIPSL}/modeles/LMDZ/DefLists/file_def_histdaystrataer_lmdz.xml",
                    ".",
                ],
                ["${MODIPSL}/modeles/LMDZ/DefLists/file_def_histLES_lmdz.xml", "."],
                [
                    "${R_IN}/ATM/AEROSOLS/CMIP6/v1/144x142/L${RESOL_ATM_Z}/aerosols1850_from_inca.nc",
                    "aerosols.nat.nc",
                ],
                [
                    "${R_IN}/ATM/AEROSOLS/CMIP6/v1/144x142/L${RESOL_ATM_Z}/aerosols1995_from_inca.nc",
                    "aerosols1980.nc",
                ],
                [
                    "${R_IN}/ATM/STRATAERO/CMIP6/v3/144x142/L${RESOL_ATM_Z}/taulwstrat.2D.ave.nc",
                    "taulwstrat.2D.nc",
                ],
                [
                    "${R_IN}/ATM/STRATAERO/CMIP6/v3/144x142/L${RESOL_ATM_Z}/tauswstrat.2D.ave.nc",
                    "tauswstrat.2D.nc",
                ],
            ],
        },
        "ParametersFiles": {
            "List": [
                ["${SUBMIT_DIR}/PARAM/LMDZ/physiq.def_${LMDZ_Physics}", "physiq.def"],
                ["${SUBMIT_DIR}/PARAM/LMDZ/vert.def_L${RESOL_ATM_Z}", "vert.def"],
                ["${SUBMIT_DIR}/PARAM/LMDZ/config.def_actuel", "config.def"],
                ["${SUBMIT_DIR}/PARAM/LMDZ/run.def", "."],
                ["${SUBMIT_DIR}/PARAM/LMDZ/tracer.def", "."],
            ]
        },
        "RestartFiles": {"List": ["NONE"]},
        "OutputText": {
            "List": [
                "physiq.def",
                "gcm.def",
                "vert.def",
                "run.def",
                "config.def",
                "tracer.def",
                "guide.def",
                "context_lmdz.xml",
                "context_input_lmdz.xml",
                "field_def_lmdz.xml",
                "file_def_*lmdz.xml",
            ]
        },
        "OutputFiles": {
            "List": [
                [
                    "limit.nc",
                    "${R_OUT_ATM_O}/Boundary/${config_UserChoices_JobName}_${year}_limit.nc",
                    "NONE",
                ],
                [
                    "climoz_LMDZ.nc",
                    "${R_OUT_ATM_O}/Boundary/${config_UserChoices_JobName}_${year}_climoz_LMDZ.nc",
                    "NONE",
                ],
                [
                    "startphy.nc",
                    "${R_OUT_ATM_O}/Restart/${config_UserChoices_JobName}_${year}_startphy.nc",
                    "NONE",
                ],
                [
                    "grid_atm.nc",
                    "${R_OUT_ATM_O}/Grid/${config_UserChoices_JobName}_${year}_grid_atm.nc",
                    "NONE",
                ],
            ]
        },
    }
test_load_orchidee
test_load_orchidee(orchidee)
Source code in tests/test_card_file_load.py
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
def test_load_orchidee(orchidee):
    assert orchidee == {
        "Compatibility": {"libIGCM": 1.0},
        "UserChoices": {
            "AtmCo2": 369.12,
            "DefSuffix": "15pft.1ac",
            "VEGET_UPDATE_at_start": False,
            "VEGET_UPDATE": "0Y",
            "ROUTING": "interp_topo",
            "output_level_sechiba_history": 5,
            "output_level_sechiba_out_2": "NONE",
            "output_level_sechiba_history_4dim": "NONE",
            "output_level_diag_routing": 1,
            "output_level_diag_routing_r": 1,
            "output_level_forcing_by_ORCHIDEE": "NONE",
            "output_freq_sechiba_history": "1mo",
            "output_freq_sechiba_out_2": "1d",
            "output_freq_sechiba_history_4dim": "1mo",
        },
        "InitialStateFiles": {
            "List": [
                ["${R_IN}/SRF/SOIL/soil_bulk_and_ph.nc", "."],
                [
                    "${R_IN}/SRF/SOIL/soils_param_usda_with_clay_oxisol_coord.nc",
                    "soils_param.nc",
                ],
                ["${R_IN}/SRF/SOIL/soils_param_zobler_coord.nc", "soilcolor.nc"],
                ["${R_IN}/SRF/cartepente2d_15min4.nc", "cartepente2d_15min.nc"],
                ["${R_IN}/SRF/reftemp4.nc", "reftemp.nc"],
                ["${R_IN}/SRF/albedo/alb_bg_optv4c_nonsmoothedvis.nc", "alb_bg.nc"],
                [
                    "${R_IN}/SRF/PFTMAPS/CMIP6/ESA-LUH2v2/historical/15PFT.v2023.1/PFTmap_2000.nc",
                    "PFTmap.nc",
                ],
            ]
        },
        "BoundaryFiles": {
            "List": [],
            "ListNonDel": ["${R_IN}/SRF/ROUTING/routing_simple.nc", "routing.nc"],
        },
        "SmoothFiles": {"List": []},
        "ParametersFiles": {
            "List": [
                ["${SUBMIT_DIR}/PARAM/ORCHIDEE/orchidee.def_v4", "orchidee.def"],
                [
                    "${SUBMIT_DIR}/PARAM/ORCHIDEE/orchidee_pft.def_${DefSuffix}_v4",
                    "orchidee_pft.def",
                ],
                ["${MODIPSL}/modeles/ORCHIDEE_4/src_xml/file_def_orchidee.xml", "."],
                [
                    "${MODIPSL}/modeles/ORCHIDEE_4/src_xml/context_input_orchidee.xml",
                    ".",
                ],
                ["${MODIPSL}/modeles/ORCHIDEE_4/src_xml/context_orchidee.xml", "."],
                [
                    "${MODIPSL}/modeles/ORCHIDEE_4/src_xml/context_routing_interp_topo_v0_orchidee_xios3.xml",
                    "context_routing_interp_topo_v0_orchidee.xml",
                ],
                [
                    "${MODIPSL}/modeles/ORCHIDEE_4/src_xml/context_routing_interp_topo_orchidee_xios3.xml",
                    "context_routing_interp_topo_orchidee.xml",
                ],
                [
                    "${MODIPSL}/modeles/ORCHIDEE_4/src_xml/context_init_routing_interp_topo_orchidee.xml",
                    ".",
                ],
                ["${MODIPSL}/modeles/ORCHIDEE_4/src_xml/field_def_orchidee.xml", "."],
            ]
        },
        "RestartFiles": {
            "List": [
                ["sechiba_rest_out.nc", "sechiba_rest.nc", "sechiba_rest_in.nc"],
                ["routing_restart.nc", "routing_restart.nc", "routing_start.nc"],
            ]
        },
        "OutputText": {
            "List": [
                "out_orchidee*",
                "orchidee.def",
                "orchidee_pft.def",
                "used_orchidee.def",
                "used_orchidee_pft.def",
                "iodef.xml",
                "context_orchidee.xml",
                "context_input_orchidee.xml",
                "context_routing_interp_topo_v0_orchidee.xml",
                "context_routing_interp_topo_orchidee.xml",
                "context_init_routing_interp_topo_orchidee.xml",
                "field_def_orchidee.xml",
                "file_def_orchidee.xml",
                "river_desc.nc",
            ]
        },
        "OutputFiles": {
            "List": [
                [
                    "sechiba_history.nc",
                    "${R_OUT_SRF_O_M}/${PREFIX}_1M_sechiba_history.nc",
                    "Post_1M_sechiba_history",
                ],
                [
                    "sechiba_history_4dim.nc",
                    "${R_OUT_SRF_O_M}/${PREFIX}_1M_sechiba_history_4dim.nc",
                    "NONE",
                ],
                [
                    "sechiba_out_2.nc",
                    "${R_OUT_SRF_O_H}/${PREFIX}_HF_sechiba_out_2.nc",
                    "NONE",
                ],
                [
                    "ORCHIDEE_interp_diag.nc",
                    "${R_OUT_SRF_O_D}/${PREFIX}_ORCHIDEE_interp_diag.nc",
                    "NONE",
                ],
                [
                    "forcing_by_ORCHIDEE.nc",
                    "${R_OUT_SRF_O_H}/${PREFIX}_forcing_by_ORCHIDEE.nc",
                    "NONE",
                ],
                [
                    "diag_routing.nc",
                    "${R_OUT_SRF_O_D}/${PREFIX}_1D_sechiba_routing.nc",
                    "NONE",
                ],
                [
                    "diag_routing_r.nc",
                    "${R_OUT_SRF_O_D}/${PREFIX}_1D_sechiba_routing_r.nc",
                    "NONE",
                ],
            ]
        },
        "Post_1M_sechiba_history": {
            "Patches": [],
            "GatherWithInternal": [
                "lon",
                "lat",
                "time_counter",
                "Areas",
                "Contfrac",
                "time_centered",
                "time_centered_bounds",
            ],
            "TimeSeriesVars2D": [
                "nobiofrac",
                "alb_nir",
                "alb_vis",
                "evap",
                "fluxlat",
                "fluxsens",
                "rain",
                "runoff",
                "snow",
                "snowf",
                "frac_snow",
                "subli",
                "tair",
                "temp_sol",
                "drainage",
                "humtot_top",
                "mrso",
                "TWBR",
                "riverflow",
                "coastalflow",
                "DelSoilMoist_daily",
                "DelIntercept_daily",
                "DelSWE_daily",
                "delstock_routing_daily",
                "LAImean",
                "transpir",
                "evapnu",
                "lwdown",
                "swdown",
                "gppCrop",
                "rhCrop",
                "Ca",
            ],
            "ChunckJob2D": "NONE",
            "TimeSeriesVars3D": [
                "lai",
                "maxvegetfrac",
                "vegetfrac",
                "nee",
                "gpp",
                "growth_resp",
                "hetero_resp",
                "humrel",
                "inter",
                "maint_resp",
                "npp",
                "precisol",
            ],
            "ChunckJob3D": "NONE",
            "Seasonal": "ON",
        },
        "Post_HF_sechiba_out_2": {
            "Patches": [],
            "GatherWithInternal": [
                "lon",
                "lat",
                "time_counter",
                "Areas",
                "Contfrac",
                "time_centered",
                "time_centered_bounds",
            ],
            "TimeSeriesVars2D": [],
            "ChunckJob2D": "NONE",
            "TimeSeriesVars3D": ["snowdz", "snowtemp", "snowrho"],
            "ChunckJob3D": "NONE",
            "Seasonal": "OFF",
        },
    }
test_load_test_card
test_load_test_card(test_card)
Source code in tests/test_card_file_load.py
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
def test_load_test_card(test_card):
    assert test_card == {
        "Messages": {
            "Option1": '"Hello Earth"',
            "Option2": '"Hello Mars"',
            "ListVal1": [],
            "ListVal2": [],
            "ListVal3": [],
        },
        "Recipes": {"Cake": '"file1.doc"', "Starter": '"file2.doc"'},
        "ColorValues": {"Red": 120, "Blue": 230, "Green": 178, "AnotherRed": 234},
        "Couples": {
            "List1": [
                ["up", "down"],
                ["humid", "dry"],
                ["hot", "cold"],
                ["far", "close"],
            ],
            "List2": ["ice", "fire", "air", "water"],
        },
    }
test_load_xios
test_load_xios(xios)
Source code in tests/test_card_file_load.py
598
599
600
601
602
603
604
605
606
607
608
609
610
611
def test_load_xios(xios):
    assert xios == {
        "Compatibility": {"libIGCM": 1.0},
        "UserChoices": {},
        "InitialStateFiles": {"List": []},
        "BoundaryFiles": {"List": [], "ListNonDel": []},
        "SmoothFiles": {"List": []},
        "ParametersFiles": {"List": ["${SUBMIT_DIR}/PARAM/XIOS/iodef.xml", "."]},
        "RestartFiles": {"List": ["NONE"]},
        "OutputText": {
            "List": ["xios_client_*", "out_xios.x.err.*", "out_xios.x.out.*"]
        },
        "OutputFiles": {"List": []},
    }
xios
xios()
Source code in tests/test_card_file_load.py
593
594
595
@pytest.fixture
def xios():
    return _load_file("xios.card.r7417")

test_def_file

Functions

all_datatypes
all_datatypes()
Source code in tests/test_def_file.py
20
21
22
@pytest.fixture
def all_datatypes():
    return _load_file("all_datatypes.def")
all_datatypes_dump
all_datatypes_dump()
Source code in tests/test_def_file.py
25
26
27
@pytest.fixture
def all_datatypes_dump():
    return _open_file("all_datatypes.def.dump")
all_datatypes_with_positions
all_datatypes_with_positions()
Source code in tests/test_def_file.py
30
31
32
@pytest.fixture
def all_datatypes_with_positions():
    return _load_file("all_datatypes.def", include_positions=True)
config_actuel
config_actuel()
Source code in tests/test_def_file.py
35
36
37
@pytest.fixture
def config_actuel():
    return _load_file("config.def_actuel.r7417")
earth_const
earth_const()
Source code in tests/test_def_file.py
40
41
42
@pytest.fixture
def earth_const():
    return _load_file("earth_const.def.r7417")
earth_const_dump
earth_const_dump()
Source code in tests/test_def_file.py
45
46
47
@pytest.fixture
def earth_const_dump():
    return _open_file("earth_const.def.r7417.dump")
earth_const_with_positions
earth_const_with_positions()
Source code in tests/test_def_file.py
50
51
52
@pytest.fixture
def earth_const_with_positions():
    return _load_file("earth_const.def.r7417", include_positions=True)
gcm_144x142_NPv63
gcm_144x142_NPv63()
Source code in tests/test_def_file.py
55
56
57
@pytest.fixture
def gcm_144x142_NPv63():
    return _load_file("gcm.def_144x142_NPv6.3.r7417")
orchidee_v22
orchidee_v22()
Source code in tests/test_def_file.py
60
61
62
@pytest.fixture
def orchidee_v22():
    return _load_file("orchidee.def_v22.r7417")
orchidee_v4
orchidee_v4()
Source code in tests/test_def_file.py
65
66
67
@pytest.fixture
def orchidee_v4():
    return _load_file("orchidee.def_v4.r7445")
physiq_NPv650
physiq_NPv650()
Source code in tests/test_def_file.py
70
71
72
@pytest.fixture
def physiq_NPv650():
    return _load_file("physiq.def_NPv6.5.0.r7417")
run_dynamico_lam_ERA5_France
run_dynamico_lam_ERA5_France()
Source code in tests/test_def_file.py
85
86
87
@pytest.fixture
def run_dynamico_lam_ERA5_France():
    return _load_file("run_dynamico_lam_ERA5_France.def.r7417")
run_dynamico_nbp60
run_dynamico_nbp60()
Source code in tests/test_def_file.py
80
81
82
@pytest.fixture
def run_dynamico_nbp60():
    return _load_file("run_dynamico.def_nbp60.r7417")
run_lmdz
run_lmdz()
Source code in tests/test_def_file.py
75
76
77
@pytest.fixture
def run_lmdz():
    return _load_file("run.def.r7417")
test_all_datatypes_dumps
test_all_datatypes_dumps(all_datatypes, all_datatypes_dump)
Source code in tests/test_def_file.py
233
234
def test_all_datatypes_dumps(all_datatypes, all_datatypes_dump):
    assert dumps(all_datatypes) == all_datatypes_dump
test_all_datatypes_dumps_loads
test_all_datatypes_dumps_loads(all_datatypes)
Source code in tests/test_def_file.py
237
238
def test_all_datatypes_dumps_loads(all_datatypes):
    assert all_datatypes == loads(dumps(all_datatypes))
test_all_datatypes_load
test_all_datatypes_load(all_datatypes)
Source code in tests/test_def_file.py
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
def test_all_datatypes_load(all_datatypes):
    assert all_datatypes == {
        "INCLUDEDEF": ["module1", "module2.def", '"module3.def"'],
        "array_floats": [3.3, 4.4, 1.3, 3.1],
        "array_integers": [1, 2, 3, 4],
        "array_mixed": [1, 10000000000.0, 13.31, "test1", "'test2'", '"test2"'],
        "array_strings": ["test1", "test2", "test3"],
        "auto": ("_AUTO_", None),
        "auto_default_float": ("_AUTO_", 0.25),
        "auto_default_integer": ("_AUTO_", 23),
        "auto_default_quoted_string": ("_AUTO_", '"some string"'),
        "auto_default_string": ("_AUTO_", "somestring"),
        "autoblocker": ("_AUTOBLOCKER_", None),
        "autoblocker_default": ("_AUTOBLOCKER_", 3.33),
        "float": 0.25,
        "float_negative": -0.25,
        "float_positive": 0.25,
        "float_scientific": 1476.48,
        "float_scientific_negative": -1476.48,
        "float_scientific_zero": 0.0,
        "integer": 23,
        "integer_negative": -23,
        "integer_positive": 23,
        "integer_zero": 0,
        "logical_false1": False,
        "logical_false2": False,
        "logical_false3": False,
        "logical_false4": False,
        "logical_false5": False,
        "logical_true1": True,
        "logical_true2": True,
        "logical_true3": True,
        "logical_true4": True,
        "logical_true5": True,
        "string": "somestring",
        "string_double_quotes": '"some string"',
        "string_single_quotes": "'some string'",
        "string_special": "_somestring123__",
    }
test_all_datatypes_load_with_positions
test_all_datatypes_load_with_positions(
    all_datatypes_with_positions,
)
Source code in tests/test_def_file.py
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
def test_all_datatypes_load_with_positions(all_datatypes_with_positions):
    assert all_datatypes_with_positions == {
        "logical_true1": {"value": True, "start_pos": 152, "end_pos": 153},
        "logical_true2": {"value": True, "start_pos": 168, "end_pos": 169},
        "logical_true3": {"value": True, "start_pos": 184, "end_pos": 188},
        "logical_true4": {"value": True, "start_pos": 203, "end_pos": 207},
        "logical_true5": {"value": True, "start_pos": 222, "end_pos": 226},
        "logical_false1": {"value": False, "start_pos": 243, "end_pos": 244},
        "logical_false2": {"value": False, "start_pos": 260, "end_pos": 261},
        "logical_false3": {"value": False, "start_pos": 277, "end_pos": 282},
        "logical_false4": {"value": False, "start_pos": 298, "end_pos": 303},
        "logical_false5": {"value": False, "start_pos": 319, "end_pos": 324},
        "integer": {"value": 23, "start_pos": 334, "end_pos": 336},
        "integer_negative": {"value": -23, "start_pos": 354, "end_pos": 357},
        "integer_positive": {"value": 23, "start_pos": 375, "end_pos": 378},
        "integer_zero": {"value": 0, "start_pos": 392, "end_pos": 393},
        "float": {"value": 0.25, "start_pos": 401, "end_pos": 405},
        "float_negative": {"value": -0.25, "start_pos": 421, "end_pos": 426},
        "float_positive": {"value": 0.25, "start_pos": 442, "end_pos": 447},
        "float_scientific": {"value": 1476.48, "start_pos": 466, "end_pos": 477},
        "float_scientific_negative": {
            "value": -1476.48,
            "start_pos": 504,
            "end_pos": 516,
        },
        "float_scientific_zero": {"value": 0.0, "start_pos": 539, "end_pos": 546},
        "string": {"value": "somestring", "start_pos": 555, "end_pos": 565},
        "string_special": {
            "value": "_somestring123__",
            "start_pos": 581,
            "end_pos": 597,
        },
        "string_single_quotes": {
            "value": "'some string'",
            "start_pos": 661,
            "end_pos": 674,
        },
        "string_double_quotes": {
            "value": '"some string"',
            "start_pos": 696,
            "end_pos": 709,
        },
        "array_integers": {"value": [1, 2, 3, 4], "start_pos": 728, "end_pos": 738},
        "array_floats": {
            "value": [3.3, 4.4, 1.3, 3.1],
            "start_pos": 754,
            "end_pos": 772,
        },
        "array_strings": {
            "value": ["test1", "test2", "test3"],
            "start_pos": 789,
            "end_pos": 808,
        },
        "array_mixed": {
            "value": [1, 10000000000.0, 13.31, "test1", "'test2'", '"test2"'],
            "start_pos": 823,
            "end_pos": 862,
        },
        "auto": {"value": ("_AUTO_", None), "start_pos": 869, "end_pos": 875},
        "auto_default_integer": {
            "value": ("_AUTO_", 23),
            "start_pos": 897,
            "end_pos": 916,
        },
        "auto_default_float": {
            "value": ("_AUTO_", 0.25),
            "start_pos": 936,
            "end_pos": 957,
        },
        "auto_default_string": {
            "value": ("_AUTO_", "somestring"),
            "start_pos": 978,
            "end_pos": 1005,
        },
        "auto_default_quoted_string": {
            "value": ("_AUTO_", '"some string"'),
            "start_pos": 1033,
            "end_pos": 1063,
        },
        "autoblocker": {
            "value": ("_AUTOBLOCKER_", None),
            "start_pos": 1077,
            "end_pos": 1090,
        },
        "autoblocker_default": {
            "value": ("_AUTOBLOCKER_", 3.33),
            "start_pos": 1111,
            "end_pos": 1137,
        },
        "INCLUDEDEF": [
            {"value": "module1", "start_pos": 11, "end_pos": 18},
            {"value": "module2.def", "start_pos": 30, "end_pos": 41},
            {"value": '"module3.def"', "start_pos": 53, "end_pos": 66},
        ],
    }
test_dynamico_earth_const_dumps
test_dynamico_earth_const_dumps(
    earth_const, earth_const_dump
)
Source code in tests/test_def_file.py
267
268
def test_dynamico_earth_const_dumps(earth_const, earth_const_dump):
    assert dumps(earth_const) == earth_const_dump
test_dynamico_earth_const_dumps_loads
test_dynamico_earth_const_dumps_loads(earth_const)
Source code in tests/test_def_file.py
271
272
def test_dynamico_earth_const_dumps_loads(earth_const):
    assert earth_const == loads(dumps(earth_const))
test_dynamico_earth_const_load
test_dynamico_earth_const_load(earth_const)
Source code in tests/test_def_file.py
241
242
243
244
245
246
247
248
249
250
251
def test_dynamico_earth_const_load(earth_const):
    assert earth_const == {
        "radius": 6.371229e6,
        "g": 9.80665,
        "omega": 7.292e-05,
        "kappa": 0.2857143,
        "cpp": 1004.70885783307,
        "preff": 101325.0,
        "scale_factor": 1.0,
        "netcdf_prec": "double",
    }
test_dynamico_earth_const_load_with_positions
test_dynamico_earth_const_load_with_positions(
    earth_const_with_positions,
)
Source code in tests/test_def_file.py
254
255
256
257
258
259
260
261
262
263
264
def test_dynamico_earth_const_load_with_positions(earth_const_with_positions):
    assert earth_const_with_positions == {
        "radius": {"value": 6371229.0, "start_pos": 50, "end_pos": 60},
        "g": {"value": 9.80665, "start_pos": 99, "end_pos": 106},
        "omega": {"value": 7.292e-05, "start_pos": 158, "end_pos": 166},
        "kappa": {"value": 0.2857143, "start_pos": 209, "end_pos": 218},
        "cpp": {"value": 1004.70885783307, "start_pos": 324, "end_pos": 340},
        "preff": {"value": 101325.0, "start_pos": 394, "end_pos": 401},
        "scale_factor": {"value": 1.0, "start_pos": 479, "end_pos": 481},
        "netcdf_prec": {"value": "double", "start_pos": 526, "end_pos": 532},
    }
test_lmdz_config_actuel_dumps_loads
test_lmdz_config_actuel_dumps_loads(config_actuel)
Source code in tests/test_def_file.py
463
464
def test_lmdz_config_actuel_dumps_loads(config_actuel):
    assert config_actuel == loads(dumps(config_actuel))
test_lmdz_config_actuel_load
test_lmdz_config_actuel_load(config_actuel)
Source code in tests/test_def_file.py
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
def test_lmdz_config_actuel_load(config_actuel):
    assert config_actuel == {
        "level_coupling_esm": ("_AUTO_", 0),
        "carbon_cycle_cpl": ("_AUTO_", False),
        "carbon_cycle_tr": ("_AUTO_", False),
        "carbon_cycle_rad": ("_AUTO_", False),
        "read_fco2_ocean_cor": ("_AUTO_", False),
        "var_fco2_ocean_cor": ("_AUTO_", 0.2576),
        "read_fco2_land_cor": ("_AUTO_", False),
        "var_fco2_land_cor": ("_AUTO_", -0.2036),
        "iflag_cycle_diurne": 1,
        "soil_model": True,
        "t_coupl": ("_AUTO_", None),
        "nbapp_rad": 16,
        "pmagic": ("_AUTO_", 0.0),
        "R_ecc": ("_AUTO_", 0.016715),
        "R_peri": ("_AUTO_", 102.7),
        "R_incl": ("_AUTO_", 23.441),
        "solaire": ("_AUTO_", 1361.20),
        "ok_suntime_rrtm": True,
        "co2_ppm": ("_AUTO_", 3.6912e02),
        "co2_ppm0": ("_AUTO_", 2.8432e02),
        "co2_ppm_per": ("_AUTO_", 14.7648e02),
        "CH4_ppb": ("_AUTO_", 1.7780e03),
        "N2O_ppb": ("_AUTO_", 3.1576e02),
        "CFC11_ppt": ("_AUTO_", 6.3990e01),
        "CFC12_ppt": ("_AUTO_", 1.0511e03),
        "ok_ade": ("_AUTO_", None),
        "ok_aie": ("_AUTO_", None),
        "aer_type": "actuel",
        "aerosol_couple": ("_AUTO_", None),
        "chemistry_couple": ("_AUTO_", None),
        "flag_aerosol": ("_AUTO_", None),
        "ok_cdnc": ("_AUTO_", None),
        "ok_alw": True,
        "read_climoz": ("_AUTO_", None),
        "flag_aerosol_strat": ("_AUTO_", 2),
        "ok_volcan": False,
        "ok_cosp": ("_AUTO_", None),
    }
test_lmdz_gcm_144x142_NPv63_dumps_loads
test_lmdz_gcm_144x142_NPv63_dumps_loads(gcm_144x142_NPv63)
Source code in tests/test_def_file.py
497
498
def test_lmdz_gcm_144x142_NPv63_dumps_loads(gcm_144x142_NPv63):
    assert gcm_144x142_NPv63 == loads(dumps(gcm_144x142_NPv63))
test_lmdz_gcm_144x142_NPv63_load
test_lmdz_gcm_144x142_NPv63_load(gcm_144x142_NPv63)
Source code in tests/test_def_file.py
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
def test_lmdz_gcm_144x142_NPv63_load(gcm_144x142_NPv63):
    assert gcm_144x142_NPv63 == {
        "day_step": 672,
        "iperiod": 7,
        "lstardis": True,
        "nitergdiv": 1,
        "nitergrot": 2,
        "niterh": 2,
        "tetagdiv": 3600.0,
        "tetagrot": 21600.0,
        "tetatemp": 10800.0,
        "coefdis": 0.0,
        "purmats": False,
        "iflag_phys": 1,
        "read_start": True,
        "iphysiq": 7,
        "clon": 0.0,
        "clat": 0.0,
        "grossismx": 1.0,
        "grossismy": 1.0,
        "fxyhypb": True,
        "dzoomx": 0.0,
        "dzoomy": 0.0,
        "taux": 3.0,
        "tauy": 3.0,
        "ysinus": True,
        "ngroup": 4,
    }
test_lmdz_physiq_NPv650_dumps_loads
test_lmdz_physiq_NPv650_dumps_loads(physiq_NPv650)
Source code in tests/test_def_file.py
684
685
def test_lmdz_physiq_NPv650_dumps_loads(physiq_NPv650):
    assert physiq_NPv650 == loads(dumps(physiq_NPv650))
test_lmdz_physiq_NPv650_load
test_lmdz_physiq_NPv650_load(physiq_NPv650)
Source code in tests/test_def_file.py
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
def test_lmdz_physiq_NPv650_load(physiq_NPv650):
    assert physiq_NPv650 == {
        "ok_limitvrai": False,
        "f_cdrag_stable": 1,
        "f_cdrag_ter": 1,
        "min_wind_speed": 0.1,
        "ifl_pbltree": 1,
        "Cd_frein": 0.016,
        "f_cdrag_oce": 1,
        "iflag_z0_oce": 1,
        "f_z0qh_oce": 1.55,
        "iflag_gusts": 2,
        "f_gust_bl": 0.845,
        "f_gust_wk": 0.2,
        "f_qsat_oce": 0.98,
        "cdmmax": 0.2,
        "cdhmax": 0.2,
        "new_yamada4": True,
        "yamada4_num": 5,
        "iflag_corr_sta": 4,
        "f_ri_cd_min": 0.01,
        "yamada4_ric": 0.18,
        "lmixmin": 0,
        "iflag_pbl": 12,
        "ksta_ter": 1e-07,
        "ksta": 1e-10,
        "ok_kzmin": False,
        "addtkeoro": 2,
        "alphatkeoro": 1,
        "smallscales_tkeoro": True,
        "nm_oro_t": 0,
        "zstd_orodr_t": 0,
        "zpmm_orodr_t": 0,
        "zpmm_orolf_t": 0,
        "ok_orodr": True,
        "ok_orolf": True,
        "f_rugoro": 0,
        "sso_gfrcri": 0.7,
        "sso_gkdrag": 0.6,
        "sso_gkwake": 0.4,
        "sso_gklift": 0.1,
        "ok_gwd_rando": True,
        "gwd_rando_ruwmax": 0.5,
        "gwd_rando_sat": 0.6,
        "gwd_front_ruwmax": 3,
        "iflag_rrtm": 1,
        "NSW": 6,
        "alb_vis_sno_lic": 0.96,
        "alb_nir_sno_lic": 0.68,
        "inertie_sno": 350,
        "iflag_sic": 1,
        "inertie_lic": 2000,
        "inertie_sic": 2000,
        "tau_gl": ("_AUTO_", 5.0),
        "iflag_albedo": 1,
        "nbapp_cv": 48,
        "ok_bad_ecmwf_thermo": False,
        "cld_lc_lsc": 0.001,
        "cld_lc_con": 0.001,
        "cld_tau_lsc": 900,
        "cld_tau_con": 900,
        "ffallv_lsc": 0.8,
        "ffallv_con": 0.8,
        "coef_eva": 0.0001,
        "iflag_evap_prec": 2,
        "t_glace_min": 243.15,
        "t_glace_max": 273.15,
        "exposant_glace": 0.5,
        "iflag_t_glace": 3,
        "iflag_ice_thermo": 1,
        "reevap_ice": False,
        "iflag_bergeron": 2,
        "iflag_fisrtilp_qsat": 4,
        "iflag_cld_th": 6,
        "fact_cldcon": 1,
        "facttemps": 0,
        "iflag_pdf": 1,
        "ok_newmicro": True,
        "iflag_ratqs": 4,
        "ratqsp0": 45000,
        "ratqsdp": 10000,
        "ratqsbas": 0.002,
        "ratqshaut": 0.4,
        "rad_froid": 35,
        "rad_chau1": 12,
        "rad_chau2": 11,
        "bl95_b0": 1.3,
        "bl95_b1": 0.2,
        "new_oliq": True,
        "oliqmax": 0.0015,
        "oicemax": 0.0015,
        "rei_min": 16,
        "rei_max": 61.29,
        "iflag_cloudth_vert": 3,
        "cloudth_vert_alpha": 0.5,
        "cloudth_vert_alpha_th": 0.5,
        "cdnc_min": 10,
        "iflag_con": 3,
        "if_ebil": 0,
        "epmax": 0.999,
        "ok_adj_ema": False,
        "iflag_clw": 0,
        "iflag_clos": 2,
        "iflag_mix": 1,
        "qqa1": 1,
        "qqa2": 0,
        "cvl_corr": 1,
        "Fmax": 0.65,
        "dpbase": -40,
        "sigdz": 0.003,
        "spfac": 0.15,
        "tau": 8000,
        "tau": 8000,
        "flag_wb": 50,
        "wbmax": 2.8,
        "ok_convstop": False,
        "tau_stop": 15000,
        "ok_intermittent": False,
        "iflag_mix_adiab": 0,
        "coef_peel": 0.25,
        "flag_epKEorig": 1,
        "elcrit": 0.0003,
        "tlcrit": -55,
        "pbcrit": 150,
        "ptcrit": 500,
        "flag_wk_check_trgl": False,
        "iflag_wk_check_trgl": 2,
        "iflag_alp_wk_cond": 1,
        "cv_flag_feed": 2,
        "ok_optim_yield": True,
        "iflag_cld_cv": 0,
        "ok_bug_cv_trac": ("_AUTO_", False),
        "ok_bug_ajs_cv": False,
        "keepbug_ice_frac": False,
        "iflag_pbl_split": 10,
        "alp_bl_k": 0.5,
        "alp_offset": 0,
        "t_top_max": 1000,
        "iflag_trig_bl": 1,
        "s_trig": 12000000,
        "tau_trig_shallow": 1200,
        "tau_trig_deep": 1200,
        "random_notrig_max": 0.99,
        "tmax_fonte_cv": 278.15,
        "iflag_clos_bl": 1,
        "stark": 0.33,
        "alpk": 0.25,
        "iflag_thermals": 18,
        "nsplit_thermals": 1,
        "tau_thermals": 0,
        "iflag_thermals_ed": 8,
        "thermals_afact": 0.666667,
        "thermals_fact_epsilon": 0.002,
        "thermals_betalpha": 0.9,
        "thermals_detr_q_coef": 0.012,
        "cloudth_sigma1s_factor": 1.1,
        "cloudth_sigma2s_factor": 0.09,
        "fact_thermals_ed_dz": 0.07,
        "iflag_thermals_optflux": 0,
        "iflag_coupl": 5,
        "seuil_inversion": -0.08,
        "iflag_thermals_closure": 2,
        "iflag_wake": 1,
        "coefgw": 4,
        "wdens_ref_o": 1e-09,
        "wdens_ref_l": 8e-12,
        "ok_adjwk": True,
        "ok_bug_gfl": False,
        "iflag_wk_profile": 1,
        "wk_pupper": 3.5,
        "wk_frac_int_delta_t": 0.75,
        "wk_delta_t_min": 0,
        "iflag_wk_new_ptop": 2,
        "ok_bug_zg_wk_pbl": False,
        "ok_bug_split_th": False,
        "iflag_ener_conserv": 10,
        "ok_conserv_q": True,
        "fl_cor_ebil": 1,
        "ok_lic_cond": True,
        "adjust_tropopause": True,
    }
test_lmdz_vert_L95_dumps_loads
test_lmdz_vert_L95_dumps_loads(vert_L95)
Source code in tests/test_def_file.py
716
717
def test_lmdz_vert_L95_dumps_loads(vert_L95):
    assert vert_L95 == loads(dumps(vert_L95))
test_lmdz_vert_L95_load
test_lmdz_vert_L95_load(vert_L95)
Source code in tests/test_def_file.py
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
def test_lmdz_vert_L95_load(vert_L95):
    assert vert_L95 == {
        "vert_sampling": "strato_custom",
        "iflag_top_bound": 2,
        "tau_top_bound": 0.0005,
        "mode_top_bound": 3,
        "llm": 95,
        "disvert": "strato_custom",
        "iflag_sponge": 2,
        "tau_sponge": 5e-4,
        "mode_sponge": 1,
        "vert_scale": 7.0,
        "vert_dzmin": 0.017,
        "vert_dzlow": 0.009,
        "vert_z0low": 2.0,
        "vert_dzmid": 1.1,
        "vert_z0mid": 6,
        "vert_h_mid": 17,
        "vert_dzhig": 10,
        "vert_z0hig": 75.0,
        "vert_h_hig": 20.0,
        "vert_prof_dissip": 1,
        "dissip_zref": 50,
        "ok_strato": True,
        "ok_hines": False,
    }
test_orchidee_v22_dumps_loads
test_orchidee_v22_dumps_loads(orchidee_v22)
Source code in tests/test_def_file.py
1014
1015
def test_orchidee_v22_dumps_loads(orchidee_v22):
    assert orchidee_v22 == loads(dumps(orchidee_v22))
test_orchidee_v22_load
test_orchidee_v22_load(orchidee_v22)
Source code in tests/test_def_file.py
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
def test_orchidee_v22_load(orchidee_v22):
    assert orchidee_v22 == {
        "ALB_BG_FILE": "alb_bg.nc",
        "ALB_BG_MODIS": True,
        "ALB_LEAF_NIR": [
            0.0,
            0.23,
            0.18,
            0.18,
            0.2,
            0.24,
            0.15,
            0.26,
            0.2,
            0.24,
            0.27,
            0.28,
            0.26,
            0.24,
            0.24,
        ],
        "ALB_LEAF_VIS": [
            0.0,
            0.04,
            0.04,
            0.04,
            0.04,
            0.03,
            0.03,
            0.03,
            0.03,
            0.06,
            0.06,
            0.06,
            0.06,
            0.06,
            0.06,
        ],
        "ALWAYS_INIT": [
            True,
            True,
            True,
            True,
            True,
            True,
            True,
            True,
            True,
            True,
            False,
            True,
            True,
            False,
            True,
        ],
        "ATM_CO2": ("_AUTO_", 284.32),
        "CARBON_TAU_IPASSIVE": 300,
        "CARBON_TAU_ISLOW": 7,
        "CDRAG_from_GCM": True,
        "CHEMISTRY_BVOC": ("_AUTO_", False),
        "CO2_FOR_BVOC_POSSELL": False,
        "CO2_FOR_BVOC_WILKINSON": False,
        "CWRR_AKS_A0": 0.0,
        "CWRR_AKS_POWER": 0.0,
        "CWRR_NKS_A0": 0.0,
        "CWRR_NKS_POWER": 0.0,
        "DEPTH_MAX_T": 90,
        "DOWNREGULATION_CO2_BASELEVEL": 380.0,
        "DOWNREGULATION_CO2_NEW": True,
        "DO_RSOIL": False,
        "DO_WOOD_HARVEST": ("_AUTO_", True),
        "FIRE_DISABLE": True,
        "FORCE_CO2_VEG": ("_AUTO_", False),
        "FRAC_GROWTHRESP__02": 0.35,
        "FRAC_GROWTHRESP__03": 0.35,
        "FRAC_GROWTHRESP__04": 0.28,
        "FRAC_GROWTHRESP__05": 0.28,
        "FRAC_GROWTHRESP__06": 0.28,
        "FRAC_GROWTHRESP__07": 0.35,
        "FRAC_GROWTHRESP__08": 0.35,
        "FRAC_GROWTHRESP__09": 0.35,
        "FRAC_GROWTHRESP__10": 0.28,
        "FRAC_GROWTHRESP__11": 0.28,
        "FRAC_GROWTHRESP__12": 0.28,
        "FRAC_GROWTHRESP__13": 0.28,
        "FRAC_GROWTHRESP__14": 0.35,
        "FRAC_GROWTHRESP__15": 0.35,
        "HYDROL_CWRR": True,
        "LAI_MAP": ("_AUTO_", False),
        "LAI_MAX__02": 7.0,
        "LAI_MAX__03": 5.0,
        "LAI_MAX__04": 5.0,
        "LAI_MAX__05": 4.0,
        "LAI_MAX__06": 5.0,
        "LAI_MAX__07": 3.5,
        "LAI_MAX__08": 4.0,
        "LAI_MAX__09": 3.0,
        "LAI_MAX__10": 2.5,
        "LAI_MAX__11": 2.0,
        "LAI_MAX__12": 5.0,
        "LAI_MAX__13": 5.0,
        "LAI_MAX__14": 2.5,
        "LAI_MAX__15": 2.0,
        "MAINT_RESP_SLOPE_C__02": 0.12,
        "MAINT_RESP_SLOPE_C__03": 0.12,
        "MAINT_RESP_SLOPE_C__04": 0.16,
        "MAINT_RESP_SLOPE_C__05": 0.16,
        "MAINT_RESP_SLOPE_C__06": 0.16,
        "MAINT_RESP_SLOPE_C__07": 0.25,
        "MAINT_RESP_SLOPE_C__08": 0.25,
        "MAINT_RESP_SLOPE_C__09": 0.25,
        "MAINT_RESP_SLOPE_C__10": 0.16,
        "MAINT_RESP_SLOPE_C__11": 0.12,
        "MAINT_RESP_SLOPE_C__12": 0.16,
        "MAINT_RESP_SLOPE_C__13": 0.12,
        "MAINT_RESP_SLOPE_C__14": 0.12,
        "MAINT_RESP_SLOPE_C__15": 0.25,
        "NVM": 15,
        "OK_EXPLICITSNOW": True,
        "OK_FREEZE": True,
        "PFT_NAME__10": "'temperate C3           grass      '",
        "PFT_NAME__14": "'tropical  C3           grass      '",
        "PFT_NAME__15": "'boreal    C3           grass      '",
        "PFT_TO_MTC": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 10, 10],
        "PRINTLEV": 1,
        "READ_REFTEMP": True,
        "RIVER_DESC": ("_AUTO_", None),
        "RIVER_ROUTING": ("_AUTO_", None),
        "ROUGH_DYN": True,
        "ROUTING_METHOD": ("_AUTO_", None),
        "SECHIBA_QSINT": 0.02,
        "SECHIBA_reset_time": True,
        "SECHIBA_restart_in": ("_AUTOBLOCKER_", None),
        "SNOWA_AGED_NIR": [
            0.5,
            0,
            0,
            0.1,
            0.37,
            0.08,
            0.16,
            0.17,
            0.27,
            0.44,
            0.44,
            0.44,
            0.44,
            0.44,
            0.44,
        ],
        "SNOWA_AGED_VIS": [
            0.74,
            0,
            0,
            0.08,
            0.24,
            0.07,
            0.18,
            0.18,
            0.33,
            0.57,
            0.57,
            0.57,
            0.57,
            0.57,
            0.57,
        ],
        "SNOWA_DEC_NIR": [
            0.13,
            0,
            0,
            0.1,
            0.1,
            0.16,
            0.04,
            0.07,
            0.08,
            0.12,
            0.12,
            0.12,
            0.12,
            0.12,
            0.12,
        ],
        "SNOWA_DEC_VIS": [
            0.21,
            0,
            0,
            0.14,
            0.08,
            0.17,
            0.05,
            0.06,
            0.09,
            0.15,
            0.15,
            0.15,
            0.15,
            0.15,
            0.15,
        ],
        "SOILALB_FILE": "soilcolor.nc",
        "SOILCLASS_FILE": "soils_param.nc",
        "SOILTYPE_CLASSIF": "zobler",
        "STOMATE_OK_CO2": True,
        "STOMATE_OK_STOMATE": ("_AUTOBLOCKER_", None),
        "STOMATE_RESTART_FILEIN": ("_AUTOBLOCKER_", None),
        "STRESS_GM": [
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
        ],
        "STRESS_GS": [
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
        ],
        "STRESS_VCMAX": [
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
        ],
        "TCST_SNOWA": 10.0,
        "VCMAX25__02": 45.0,
        "VCMAX25__03": 45.0,
        "VCMAX25__04": 35.0,
        "VCMAX25__05": 40.0,
        "VCMAX25__06": 50.0,
        "VCMAX25__07": 45.0,
        "VCMAX25__08": 35.0,
        "VCMAX25__09": 35.0,
        "VCMAX25__10": 50.0,
        "VCMAX25__11": 50.0,
        "VCMAX25__12": 60.0,
        "VCMAX25__13": 60.0,
        "VCMAX25__14": 50.0,
        "VCMAX25__15": 40.0,
        "VEGET_UPDATE": ("_AUTO_", None),
        "WETNESS_TRANSPIR_MAX": [
            0.8,
            0.8,
            0.8,
            0.8,
            0.8,
            0.8,
            0.8,
            0.8,
            0.8,
            0.8,
            0.8,
            0.8,
            0.8,
        ],
        "WRITE_STEP": 0,
        "XIOS_ORCHIDEE_OK": True,
    }
test_orchidee_v4_dumps_loads
test_orchidee_v4_dumps_loads(orchidee_v4)
Source code in tests/test_def_file.py
1082
1083
def test_orchidee_v4_dumps_loads(orchidee_v4):
    assert orchidee_v4 == loads(dumps(orchidee_v4))
test_orchidee_v4_load
test_orchidee_v4_load(orchidee_v4)
Source code in tests/test_def_file.py
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
def test_orchidee_v4_load(orchidee_v4):
    assert orchidee_v4 == {
        "ALB_BG_FILE": "alb_bg.nc",
        "ALB_BG_MODIS": True,
        "ATM_CO2": ("_AUTO_", 284.32),
        "CHEMISTRY_BVOC": ("_AUTO_", False),
        "CNLEAF_VAR": "CN_LEAF",
        "CO2_FOR_BVOC_POSSELL": False,
        "CO2_FOR_BVOC_WILKINSON": False,
        "ENERGY_CONTROL": 2,
        "ERR_ACT": 1,
        "FORCE_CO2_VEG": ("_AUTO_", False),
        "FR_CENTER_C": -1.0,
        "HACK_KB_M1": True,
        "HACK_PWC_H": True,
        "IMPOSE_VEG": False,
        "NCIRC": 3,
        "NINPUT_UPDATE": ("_AUTO_", None),
        "NSNOW": 12,
        "Nammonium_FILE": "Nammonium.nc",
        "Nammonium_VAR": "nhx",
        "Nbnf_FILE": "bnf.nc",
        "Nbnf_VAR": "BNF_MGN_PERM2_PERYR",
        "Nfert_ammo_cropland_FILE": "Nfert_ammo_cropland.nc",
        "Nfert_ammo_cropland_VAR": "nfer_crop_nh4",
        "Nfert_ammo_pasture_FILE": "Nfert_ammo_pasture.nc",
        "Nfert_ammo_pasture_VAR": "nfer_pas_nh4",
        "Nfert_nitr_cropland_FILE": "Nfert_nitr_cropland.nc",
        "Nfert_nitr_cropland_VAR": "nfer_crop_no3",
        "Nfert_nitr_pasture_FILE": "Nfert_nitr_pasture.nc",
        "Nfert_nitr_pasture_VAR": "nfer_pas_no3",
        "Nnitrate_FILE": "Nnitrate.nc",
        "Nnitrate_VAR": "noy",
        "OK_EXPLICITSNOW": True,
        "OK_FREEZE": True,
        "OK_READ_FM_MAP": True,
        "PRINTLEV": 1,
        "RATIO_Z0M_Z0H": 10.0,
        "RIVER_DESC": ("_AUTO_", None),
        "RIVER_ROUTING": ("_AUTO_", None),
        "ROUGH_DYN": True,
        "ROUTING_METHOD": ("_AUTO_", None),
        "RSOIL_SCALE": 1.0,
        "SECHIBA_restart_in": ("_AUTOBLOCKER_", None),
        "SOILALB_FILE": "soilcolor.nc",
        "SOILTYPE_CLASSIF": "usda",
        "SPINUP_ANALYTIC": False,
        "SPINUP_PERIOD": 10,
        "STOMATE_IMPOSE_CN": ("_AUTO_", None),
        "STOMATE_OK_STOMATE": ("_AUTOBLOCKER_", None),
        "STOMATE_READ_CN": False,
        "STOMATE_RESTART_FILEIN": ("_AUTOBLOCKER_", None),
        "TCST_SNOWA": 15.0,
        "TEST_ALB_RT_BGSNOWBARE": True,
        "TEST_GRID": 1,
        "TEST_PFT": 2,
        "USE_RATIO_Z0M_Z0H": True,
        "USE_SOILC_INSULATION": True,
        "VEGETMAP_RESET": ("_AUTO_", None),
        "VEGET_UPDATE": ("_AUTO_", None),
        "XIOS_ORCHIDEE_OK": True,
    }
test_run_dynamico_lam_ERA5_France_dumps_loads
test_run_dynamico_lam_ERA5_France_dumps_loads(
    run_dynamico_lam_ERA5_France,
)
Source code in tests/test_def_file.py
417
418
def test_run_dynamico_lam_ERA5_France_dumps_loads(run_dynamico_lam_ERA5_France):
    assert run_dynamico_lam_ERA5_France == loads(dumps(run_dynamico_lam_ERA5_France))
test_run_dynamico_lam_ERA5_France_load
test_run_dynamico_lam_ERA5_France_load(
    run_dynamico_lam_ERA5_France,
)
Source code in tests/test_def_file.py
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
def test_run_dynamico_lam_ERA5_France_load(run_dynamico_lam_ERA5_France):
    assert run_dynamico_lam_ERA5_France == {
        "mpi_threading_mode": "funneled",
        "metric_type": "icosa_area",
        "area_center_lon": 3,
        "area_center_lat": 47,
        "area_radius": 800,
        "PS_relax_out": 3600,
        "T_relax_out": 3600,
        "U_relax_out": 3600,
        "Q_relax_out": 3600,
        "nudging_vertical_levels": "pressure",
        "guided_type": ("_AUTO_", None),
        "itau_nudging": 120,
        "nudging_zone": "area",
        "nudging_stiffness": 8,
        "nbp": 40,
        "nsplit_i": 4,
        "nsplit_j": 4,
        "omp_level_size": ("_AUTOBLOCKER_", None),
        "read_metric": False,
        "optim_it": 0,
        "dt": 30.0,
        "itau_adv": 1,
        "run_length": ("_AUTOBLOCKER_", None),
        "etat0_start_iteration_reset": ("_AUTOBLOCKER_", None),
        "write_period": 10800,
        "itau_check_conserv": 100,
        "nqtot": ("_AUTO_", 4),
        "out_pression_level": 85000,
        "start_file_name": "start",
        "restart_file_name": "restart",
        "using_oasis": ("_AUTOBLOCKER_", None),
        "tau_graddiv": 3600,
        "nitergdiv": 1,
        "tau_gradrot": 21600,
        "nitergrot": 2,
        "tau_divgrad": 10800,
        "niterdivgrad": 2,
        "physics": "phys_external",
        "itau_physics": 30,
        "create_etat0_limit": ("_AUTO_", None),
        "etat0": ("_AUTO_", None),
        "etat0_database_type": "ERA5_forcing",
        "iflag_phys": ("_AUTO_", None),
        "param_gw_method": "legacy",
        "heldsz_p0": 101080,
    }
test_run_dynamico_nbp60_dumps_loads
test_run_dynamico_nbp60_dumps_loads(run_dynamico_nbp60)
Source code in tests/test_def_file.py
363
364
def test_run_dynamico_nbp60_dumps_loads(run_dynamico_nbp60):
    assert run_dynamico_nbp60 == loads(dumps(run_dynamico_nbp60))
test_run_dynamico_nbp60_load
test_run_dynamico_nbp60_load(run_dynamico_nbp60)
Source code in tests/test_def_file.py
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
def test_run_dynamico_nbp60_load(run_dynamico_nbp60):
    assert run_dynamico_nbp60 == {
        "metric_type": "icosa_global",
        "guided_type": ("_AUTO_", None),
        "itau_nudging": 48,
        "nudging_zone": "global",
        "U_relax_in": 21600,
        "PS_relax_in": 1e30,
        "T_relax_in": 1e30,
        "Q_relax_in": 1e30,
        "guide_U": True,
        "mpi_threading_mode": "funneled",
        "nbp": 60,
        "nsplit_i": 6,
        "nsplit_j": 6,
        "omp_level_size": ("_AUTOBLOCKER_", None),
        "read_metric": ("_AUTO_", None),
        "optim_it": ("_AUTO_", None),
        "dt": 150.0,
        "itau_adv": 1,
        "run_length": ("_AUTOBLOCKER_", None),
        "etat0_start_iteration_reset": ("_AUTOBLOCKER_", None),
        "write_period": 86400,
        "itau_check_conserv": 100,
        "nqtot": ("_AUTO_", 4),
        "out_pression_level": 85000,
        "start_file_name": "start",
        "restart_file_name": "restart",
        "using_oasis": ("_AUTOBLOCKER_", None),
        "tau_graddiv": 2400,
        "nitergdiv": 1,
        "tau_gradrot": 14400,
        "nitergrot": 2,
        "tau_divgrad": 7200,
        "niterdivgrad": 2,
        "physics": "phys_external",
        "itau_physics": 6,
        "create_etat0_limit": ("_AUTO_", None),
        "etat0": ("_AUTO_", None),
        "iflag_phys": ("_AUTO_", None),
        "param_gw_method": "legacy",
        "heldsz_p0": 101080,
    }
test_run_lmdz_dumps_loads
test_run_lmdz_dumps_loads(run_lmdz)
Source code in tests/test_def_file.py
314
315
def test_run_lmdz_dumps_loads(run_lmdz):
    assert run_lmdz == loads(dumps(run_lmdz))
test_run_lmdz_load
test_run_lmdz_load(run_lmdz)
Source code in tests/test_def_file.py
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
def test_run_lmdz_load(run_lmdz):
    assert run_lmdz == {
        "INCLUDEDEF": [
            "run_dynamico.def",
            "earth_const.def",
            "physiq.def",
            "gcm.def",
            "vert.def",
            "orchidee.def",
            "orchidee_pft.def",
            "config.def",
            "reprobus.def",
            "guide.def",
            "inca.def",
        ],
        "VEGET": ("_AUTOBLOCKER_", None),
        "adjust": False,
        "anneeref": ("_AUTOBLOCKER_", None),
        "calend": ("_AUTOBLOCKER_", None),
        "config_inca": ("_AUTOBLOCKER_", None),
        "cpl_current": True,
        "cpl_old_calving": ("_AUTO_", None),
        "dayref": ("_AUTOBLOCKER_", None),
        "iconser": 240,
        "iecri": 1,
        "iflag_phytrac": ("_AUTOBLOCKER_", 0),
        "nday": ("_AUTOBLOCKER_", None),
        "no_ter_antartique": True,
        "ok_all_xml": True,
        "ok_dynzon": False,
        "prt_level": 0,
        "raz_date": ("_AUTOBLOCKER_", None),
        "type_ocean": ("_AUTOBLOCKER_", None),
        "type_trac": ("_AUTOBLOCKER_", None),
        "use_filtre_fft": True,
        "version_ocean": "nemo",
    }
vert_L95
vert_L95()
Source code in tests/test_def_file.py
90
91
92
@pytest.fixture
def vert_L95():
    return _load_file("vert.def_L95.r7417")

test_def_file_decoder

Unit tests of DefFileDecoder

Functions

decoder
decoder()

Initialize classical decoder

Source code in tests/test_def_file_decoder.py
 8
 9
10
11
@pytest.fixture
def decoder():
    """Initialize classical decoder"""
    return DefFileDecoder()
decoder_with_positions
decoder_with_positions()

Initialize decoder with value position parsing

Source code in tests/test_def_file_decoder.py
14
15
16
17
@pytest.fixture
def decoder_with_positions():
    """Initialize decoder with value position parsing"""
    return DefFileDecoder(include_positions=True)
test_array
test_array(decoder)

Test decoding of arrays

Source code in tests/test_def_file_decoder.py
64
65
66
67
68
def test_array(decoder):
    """Test decoding of arrays"""
    assert decoder.decode("a = 1,2") == {"a": [1, 2]}
    assert decoder.decode("a = 1,2,3") == {"a": [1, 2, 3]}
    assert decoder.decode("a = a, 2, y") == {"a": ["a", 2, True]}
test_auto
test_auto(decoder)

Test decoding of auto values

Source code in tests/test_def_file_decoder.py
71
72
73
74
75
76
77
78
def test_auto(decoder):
    """Test decoding of auto values"""
    assert decoder.decode("a=_AUTO_") == {"a": ("_AUTO_", None)}
    assert decoder.decode("a=_AUTO_:DEFAULT=3.14") == {"a": ("_AUTO_", 3.14)}
    assert decoder.decode("a=_AUTOBLOCKER_") == {"a": ("_AUTOBLOCKER_", None)}
    assert decoder.decode("a=_AUTOBLOCKER_:DEFAULT='text'") == {
        "a": ("_AUTOBLOCKER_", "'text'")
    }
test_float
test_float(decoder)

Test decoding float numbers

Source code in tests/test_def_file_decoder.py
38
39
40
41
42
43
44
45
def test_float(decoder):
    """Test decoding float numbers"""
    assert decoder.decode("a=3.1415") == {"a": 3.1415}
    assert decoder.decode("a=3.14e2") == {"a": 314}
    assert decoder.decode("a=3.14e-2") == {"a": 0.0314}
    assert decoder.decode("a=-3.1415") == {"a": -3.1415}
    assert decoder.decode("a=-3.14e2") == {"a": -314}
    assert decoder.decode("a=-3.14e-2") == {"a": -0.0314}
test_include
test_include(decoder)

Test decoding of INCLUDEDEF statements

Source code in tests/test_def_file_decoder.py
20
21
22
23
24
25
def test_include(decoder):
    """Test decoding of INCLUDEDEF statements"""
    assert decoder.decode("INCLUDEDEF=module1") == {"INCLUDEDEF": ["module1"]}
    assert decoder.decode("INCLUDEDEF=module1\nINCLUDEDEF=module2") == {
        "INCLUDEDEF": ["module1", "module2"]
    }
test_integer
test_integer(decoder)

Test decoding integer numbers

Source code in tests/test_def_file_decoder.py
48
49
50
51
52
53
54
def test_integer(decoder):
    """Test decoding integer numbers"""
    assert decoder.decode("a=1") == {"a": 1}
    assert decoder.decode("a=-1") == {"a": -1}
    assert decoder.decode("a=-0") == {"a": 0}
    assert decoder.decode("a=+0") == {"a": 0}
    assert decoder.decode("a=6123") == {"a": 6123}
test_logical
test_logical(decoder)

Test decoding logical values

Source code in tests/test_def_file_decoder.py
28
29
30
31
32
33
34
35
def test_logical(decoder):
    """Test decoding logical values"""
    assert decoder.decode("a = true\nb=y\nc=TRUE") == {"a": True, "b": True, "c": True}
    assert decoder.decode("a = false\nb=n\nc=FALSE") == {
        "a": False,
        "b": False,
        "c": False,
    }
test_positions
test_positions(decoder_with_positions)

Test decoding of value positions

Source code in tests/test_def_file_decoder.py
81
82
83
84
85
86
87
def test_positions(decoder_with_positions):
    """Test decoding of value positions"""
    assert decoder_with_positions.decode("a=1\nb='text'\nc=_AUTO_:DEFAULT=3.14") == {
        "a": {"value": 1, "start_pos": 2, "end_pos": 3},
        "b": {"value": "'text'", "start_pos": 6, "end_pos": 12},
        "c": {"value": ("_AUTO_", 3.14), "start_pos": 15, "end_pos": 34},
    }
test_string
test_string(decoder)

Test decoding strings (quoted and unqoted)

Source code in tests/test_def_file_decoder.py
57
58
59
60
61
def test_string(decoder):
    """Test decoding strings (quoted and unqoted)"""
    assert decoder.decode("a=text") == {"a": "text"}
    assert decoder.decode("a='text'") == {"a": "'text'"}
    assert decoder.decode('a="text"') == {"a": '"text"'}

test_def_file_encoder

Functions

encoder
encoder()
Source code in tests/test_def_file_encoder.py
6
7
8
@pytest.fixture
def encoder():
    return DefFileEncoder()
encoder_bool_labels
encoder_bool_labels()
Source code in tests/test_def_file_encoder.py
11
12
13
@pytest.fixture
def encoder_bool_labels():
    return DefFileEncoder(truthy_value="y", falsey_value="n")
test_bool
test_bool(encoder)
Source code in tests/test_def_file_encoder.py
16
17
18
def test_bool(encoder):
    assert encoder.encode(True) == "true"
    assert encoder.encode(False) == "false"
test_bool_labels
test_bool_labels(encoder_bool_labels)
Source code in tests/test_def_file_encoder.py
21
22
23
24
25
26
27
def test_bool_labels(encoder_bool_labels):
    # Test other labels for true/false values
    # These changes are local to this test, and will not affect other tests
    encoder_bool_labels._truthy_value = "y"
    encoder_bool_labels._falsey_value = "n"
    assert encoder_bool_labels.encode(True) == "y"
    assert encoder_bool_labels.encode(False) == "n"
test_dict
test_dict(encoder)
Source code in tests/test_def_file_encoder.py
30
31
32
33
34
35
36
37
38
def test_dict(encoder):
    assert encoder.encode({"p": 1}) == "p = 1"
    assert encoder.encode({"p": 1, "q": 2}) == "p = 1\nq = 2"
    assert (
        encoder.encode({"INCLUDEDEF": ["m1", "m2"], "p": 1})
        == "INCLUDEDEF = m1\nINCLUDEDEF = m2\np = 1"
    )
    with pytest.raises(TypeError, match="cannot be of type: dict"):
        encoder.encode({"p": {"q": 2}})
test_float
test_float(encoder)
Source code in tests/test_def_file_encoder.py
41
42
43
44
45
46
def test_float(encoder):
    assert encoder.encode(-1.0) == "-1.0"
    assert encoder.encode(+1.0) == "1.0"
    assert encoder.encode(5e4) == "50000.0"
    assert encoder.encode(3.14e2) == "314.0"
    assert encoder.encode(3.14e-2) == "0.0314"
test_int
test_int(encoder)
Source code in tests/test_def_file_encoder.py
49
50
51
52
def test_int(encoder):
    assert encoder.encode(-1) == "-1"
    assert encoder.encode(+1) == "1"
    assert encoder.encode(int(5e4)) == "50000"
test_list
test_list(encoder)
Source code in tests/test_def_file_encoder.py
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
def test_list(encoder):
    assert encoder.encode([1, 2]) == "1, 2"
    assert encoder.encode([1, 2, "a"]) == "1, 2, a"
    with pytest.raises(ValueError, match="at least two elements"):
        assert encoder.encode([])
    with pytest.raises(ValueError, match="at least two elements"):
        assert encoder.encode([1])
    with pytest.raises(TypeError, match="must be simple scalars"):
        assert encoder.encode([1, {}])
    with pytest.raises(TypeError, match="must be simple scalars"):
        assert encoder.encode([1, {"p": 2}])
    with pytest.raises(TypeError, match="must be simple scalars"):
        assert encoder.encode([1, ()])
    with pytest.raises(TypeError, match="must be simple scalars"):
        assert encoder.encode([1, (2, 3)])
    with pytest.raises(TypeError, match="must be simple scalars"):
        assert encoder.encode([1, []])
    with pytest.raises(TypeError, match="must be simple scalars"):
        assert encoder.encode([1, [2, 3]])
test_tuple
test_tuple(encoder)
Source code in tests/test_def_file_encoder.py
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
def test_tuple(encoder):
    assert encoder.encode(("_AUTO_", None)) == "_AUTO_"
    assert encoder.encode(("_AUTOBLOCKER_", None)) == "_AUTOBLOCKER_"
    assert encoder.encode(("_AUTO_", True)) == "_AUTO_: DEFAULT=true"
    assert encoder.encode(("_AUTO_", 3)) == "_AUTO_: DEFAULT=3"
    assert encoder.encode(("_AUTO_", 3.14)) == "_AUTO_: DEFAULT=3.14"
    assert encoder.encode(("_AUTO_", "text")) == "_AUTO_: DEFAULT=text"
    assert encoder.encode(("_AUTO_", "'text'")) == "_AUTO_: DEFAULT='text'"
    assert encoder.encode(("_AUTO_", '"text"')) == '_AUTO_: DEFAULT="text"'
    with pytest.raises(ValueError, match="len=2"):
        assert encoder.encode(())
    with pytest.raises(ValueError, match="len=2"):
        assert encoder.encode(("_AUTO_",))
    with pytest.raises(ValueError, match="len=2"):
        assert encoder.encode(("_AUTO_", None, None))
    with pytest.raises(ValueError, match="First element"):
        assert encoder.encode(("AUTO", None))
    with pytest.raises(ValueError, match="First element"):
        assert encoder.encode((None, None))
    with pytest.raises(TypeError, match="Second element"):
        assert encoder.encode(("_AUTO_", ()))
    with pytest.raises(TypeError, match="Second element"):
        assert encoder.encode(("_AUTO_", (1, 2, 3)))
    with pytest.raises(TypeError, match="Second element"):
        assert encoder.encode(("_AUTO_", {}))
    with pytest.raises(TypeError, match="Second element"):
        assert encoder.encode(("_AUTO_", {"k1": 1, "k2": 2, "k3": 3}))
    with pytest.raises(TypeError, match="Second element"):
        assert encoder.encode(("_AUTO_", []))
    with pytest.raises(TypeError, match="Second element"):
        assert encoder.encode(("_AUTO_", [1, 2, 3]))

test_envmodules

Functions

test_on_spirit
test_on_spirit()
Source code in tests/test_envmodules.py
 7
 8
 9
10
11
12
13
14
15
16
@pytest.mark.skipif(
    not is_espri_spiritx(), reason="This test can be run only on ESPRI/SpiritX"
)
def test_on_spirit():
    modules = EnvModules()
    assert modules.list_loaded() == []
    assert "gcc/13.2.0" in modules.list_available()
    assert modules.purge()
    assert modules.load("gcc/13.2.0", "cdo/2.3.0")
    assert modules.list_loaded() == ["cdo/2.3.0", "gcc/13.2.0"]

test_mod_file

Functions

configs
configs(mod_file)
Source code in tests/test_mod_file.py
20
21
22
@pytest.fixture
def configs(mod_file):
    return mod_file["configuration"]
grisli
grisli(configs)
Source code in tests/test_mod_file.py
35
36
37
@pytest.fixture
def grisli(configs):
    return configs["GRISLI"]
ioipsl
ioipsl(configs)
Source code in tests/test_mod_file.py
25
26
27
@pytest.fixture
def ioipsl(configs):
    return configs["IOIPSL_PLUS"]
ipslcm7
ipslcm7(configs)
Source code in tests/test_mod_file.py
30
31
32
@pytest.fixture
def ipslcm7(configs):
    return configs["IPSLCM7.0"]
mod_file
mod_file()
Source code in tests/test_mod_file.py
 8
 9
10
11
12
@pytest.fixture
def mod_file():
    root = Path(__file__).parent.resolve()
    with open(root / "examples" / "modipsl" / "mod.def.r7473") as f:
        return load(f)
nemo_v40
nemo_v40(configs)
Source code in tests/test_mod_file.py
40
41
42
@pytest.fixture
def nemo_v40(configs):
    return configs["NEMO_v4.0"]
repos
repos(mod_file)
Source code in tests/test_mod_file.py
15
16
17
@pytest.fixture
def repos(mod_file):
    return mod_file["repository"]
test_configuration
test_configuration(configs)
Source code in tests/test_mod_file.py
49
50
def test_configuration(configs):
    assert len(configs) == 62
test_git_path_repository
test_git_path_repository(repos)
Source code in tests/test_mod_file.py
69
70
71
72
73
74
def test_git_path_repository(repos):
    # Test local repo with a path
    assert repos[24] == {
        "type": "git",
        "clone_url": "/ccc/work/cont003/igcmg/igcmg/IGCM/LIC/ELMERICE/elmerfem",
    }
test_git_repository
test_git_repository(repos)
Source code in tests/test_mod_file.py
53
54
55
56
57
58
def test_git_repository(repos):
    # Test classic git repo
    assert repos[7] == {
        "type": "git",
        "clone_url": "https://gitlab.in2p3.fr/ipsl/projets/nemogcm/nemo.git",
    }
test_grisli_configuration
test_grisli_configuration(grisli)
Source code in tests/test_mod_file.py
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
def test_grisli_configuration(grisli):
    # GRISLI configuration is interesting to test, because it has
    # identical name of the second and the third components: GRISLI
    # This is the use case that forbids us from using dictionary to
    # store componets by their name ;(
    assert grisli == {
        "description": ["GRISLI stand-alone for Antarctica icesheets (prototype)"],
        "components": [
            {
                "name": "libIGCM",
                "variant": "trunk/libIGCM",
                "revision": "HEAD",
                "repository": 10,
                "modipsl_dir": ".",
            },
            {
                "name": "GRISLI",
                "variant": "branches/xios",
                "revision": "HEAD",
                "repository": 26,
                "modipsl_dir": "modeles",
            },
            {
                "name": "GRISLI",
                "variant": "CONFIG/GRISLI",
                "revision": "HEAD",
                "repository": 8,
                "modipsl_dir": "config",
            },
            {
                "name": "XIOS",
                "variant": "XIOS3_2902",
                "revision": "243e0b53",
                "repository": 12,
                "modipsl_dir": "modeles",
            },
        ],
    }
test_ioipsl_config
test_ioipsl_config(ioipsl)
Source code in tests/test_mod_file.py
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
def test_ioipsl_config(ioipsl):
    # Test parsing of the configuration description
    assert ioipsl == {
        "description": [
            "IOIPSL contains source for library and for rebuild",
            "IOIPSL last tagged public version",
        ],
        "components": [
            {
                "name": "IOIPSL",
                "variant": "IOIPSL/tags/v2_2_5",
                "revision": "HEAD",
                "repository": 8,
                "modipsl_dir": "modeles",
            }
        ],
    }
test_ipslcm7_config
test_ipslcm7_config(ipslcm7)
Source code in tests/test_mod_file.py
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
def test_ipslcm7_config(ipslcm7):
    # Test parsing of the configuration description
    assert ipslcm7 == {
        "description": [
            "IPSLCM7.0 1st coupled configuration in CM7 family",
            "With this configuration icosa grid or reg grid can be used (user choice)",
            "IPSLCM7 can be use in full coupled configuration or with forced subconfiguration",
            "Regular subconfiguration (without ocean) give same results than with IPSLCM6.2.4",
            "NEMO v4.2.2",
            "XIOS2 branches/XIOS2 07f8fdd9 (SVN : XIOS2/trunk revision 2626)",
            "IOIPSL tags v2_2_5",
            "DYNAMICO master 73d9b2d9",
            "ICOSA_LMDZ rev 4858",
            "LMDZ6 trunk revision 4938",
            "ORCHIDEE_2_2 default : branches/ORCHIDEE_2_2 revision 8572",
            "ORCHIDEE_4 optional  : trunk revision 8571",
            "INCA6 trunk revison  1151",
            "OASIS3-MCT 2.0_branch (rev 1818 Cerfacs server, rev 6331 IPSL server)",
            "CONFIG/IPSLCM7 rev 6881",
            "libIGCM trunk rev 1659",
        ],
        "components": [
            {
                "name": "DYNAMICO",
                "variant": "master",
                "revision": "73d9b2d9",
                "repository": 21,
                "modipsl_dir": "modeles",
            },
            {
                "name": "ICOSA_LMDZ",
                "variant": "ICOSA_LMDZ",
                "revision": "4897",
                "repository": 20,
                "modipsl_dir": "modeles",
            },
            {
                "name": "IOIPSL",
                "variant": "IOIPSL/tags/v2_2_5",
                "revision": "6644",
                "repository": 8,
                "modipsl_dir": "modeles",
            },
            {
                "name": "ORCHIDEE_2_2",
                "variant": "branches/ORCHIDEE_2_2/ORCHIDEE",
                "revision": "8572",
                "repository": 14,
                "modipsl_dir": "modeles",
            },
            {
                "name": "ORCHIDEE_4",
                "variant": "trunk/ORCHIDEE",
                "revision": "8571",
                "repository": 14,
                "modipsl_dir": "modeles",
            },
            {
                "name": "oasis3-mct",
                "variant": "CPL/oasis3-mct/branches/OASIS3-MCT_5.0_branch",
                "revision": "6331",
                "repository": 8,
                "modipsl_dir": ".",
            },
            {
                "name": "LMDZ",
                "variant": "LMDZ6/trunk",
                "revision": "4938",
                "repository": 20,
                "modipsl_dir": "modeles",
            },
            {
                "name": "IPSLCM7",
                "variant": "CONFIG/UNIFORM/v7/IPSLCM7",
                "revision": "6886",
                "repository": 8,
                "modipsl_dir": "config",
            },
            {
                "name": "ORCHIDEE_OL_2_2",
                "variant": "branches/ORCHIDEE_2_2/ORCHIDEE_OL",
                "revision": "8572",
                "repository": 14,
                "modipsl_dir": "config",
            },
            {
                "name": "ORCHIDEE_OL_4",
                "variant": "trunk/ORCHIDEE_OL",
                "revision": "8571",
                "repository": 14,
                "modipsl_dir": "config",
            },
            {
                "name": "libIGCM",
                "variant": "trunk/libIGCM",
                "revision": "1659",
                "repository": 10,
                "modipsl_dir": ".",
            },
            {
                "name": "NEMO",
                "variant": "4.2.2",
                "revision": "7f5d8137",
                "repository": 22,
                "modipsl_dir": "modeles",
            },
            {
                "name": "INCA",
                "variant": "INCA",
                "revision": "INCA6@1151",
                "repository": 9,
                "modipsl_dir": "modeles",
            },
            {
                "name": "XIOS",
                "variant": "XIOS2",
                "revision": "07f8fdd9",
                "repository": 12,
                "modipsl_dir": "modeles",
            },
        ],
    }
test_nemo_v40_confguration
test_nemo_v40_confguration(nemo_v40)
Source code in tests/test_mod_file.py
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
def test_nemo_v40_confguration(nemo_v40):
    # NEMO_v4.0 is interesting to test, because it doesn't contain
    # the last optional column which usually contains duplicated
    # names of components (we don't parse it anyway).
    assert nemo_v40 == {
        "description": [
            "NEMOGCM v4.0.7, first version of NEMOv4 ( Initially NEMO_v6.5 )",
            "libIGCM trunk rev 1534",
            "XIOS branches/XIOS2 4b547204 (SVN : XIOS/trunk revision 1866)",
        ],
        "components": [
            {
                "name": "libIGCM",
                "variant": "trunk/libIGCM",
                "revision": "1581",
                "repository": 10,
                "modipsl_dir": ".",
            },
            {
                "name": "NEMO",
                "variant": "r4.0.7",
                "revision": "baad91e5",
                "repository": 7,
                "modipsl_dir": "modeles",
            },
            {
                "name": "NEMO_v6",
                "variant": "CONFIG/UNIFORM/v6/NEMO_v6.5",
                "revision": "6400",
                "repository": 8,
                "modipsl_dir": "config",
            },
            {
                "name": "XIOS",
                "variant": "XIOS2",
                "revision": "4b547204",
                "repository": 12,
                "modipsl_dir": "modeles",
            },
        ],
    }
test_repository
test_repository(repos)
Source code in tests/test_mod_file.py
45
46
def test_repository(repos):
    assert len(repos) == 19
test_svn_repository
test_svn_repository(repos)
Source code in tests/test_mod_file.py
61
62
63
64
65
66
def test_svn_repository(repos):
    # Test classic svn repo with --username flag
    assert repos[10] == {
        "type": "svn",
        "clone_url": "--username icmc_users https://forge.ipsl.fr/libigcm/svn",
    }
test_svn_ssh_repository
test_svn_ssh_repository(repos)
Source code in tests/test_mod_file.py
77
78
79
80
81
82
def test_svn_ssh_repository(repos):
    # Test repo over svn+ssh protocol
    assert repos[26] == {
        "type": "svn",
        "clone_url": "svn+ssh://<login>@forge.ipsl.fr/ipsl/forge/projets/grisli/svn/",
    }