Skip to content

Latest commit

 

History

History
83 lines (56 loc) · 3 KB

File metadata and controls

83 lines (56 loc) · 3 KB

NOAA-GSL

Coding Challenge

Instructions: Given the two sample namelist fortran files in this repo, please write a Python based tool that gives a user a command line interface that takes file paths as input and provides a report on the differences between the two files as output. For context, Fortran doesn't care about section/key order, so it's often difficult for users to track down differences in values that two researchers may have prepared independently.

Getting Started with f90nml (A Python module for Fortran namelists)

The latest documentation for f90nml can be found at https://f90nml.readthedocs.io/en/latest/

Installation

$ pip install f90nml

Set Up

Clone the repository

$ git clone https://github.com/nbharwani11/NOAA-GSL.git

Executing the Code

Once you have cloned the repository and have installed f90nml perform the following operations:

$ cd src
$ python compare_nml_files.py insert_filepath_nml_1 insert_filepath_nml_2

or

$ ./compare_nml_files.py insert_filepath_nml_1 insert_filepath_nml_2

Running pytest

I mainly followed the tutorial listed here

Following their guidelines perform the operations below:

$ mkdir pytest_project
$ cd pytest_project
$ python3 -m venv pytest-env
$ source pytest-env/bin/activate
$ pip install pytest

Now execute the pytest command $ pytest to run the tests

  • Be sure to follow the styling guidelines in the link provided (i.e. Pytest expects our tests to be located in files whose names begin with test_ or end with _test.py)

Sources

Below are my sources that I used to complete the coding challenge