Metadata-Version: 2.4
Name: romsinpy
Version: 1.0.0
Summary: Parser for ROMS .in configuration files
Author-email: YP-Shao <bluefatshao@gmail.com>
Maintainer-email: YP-Shao <bluefatshao@gmail.com>
License: GPL-3.0-or-later
Keywords: ROMS,COAWST
Requires-Python: >=3.8
Description-Content-Type: text/markdown

# ROMSInParser

A lightweight Python parser for **ROMS (`.in`) configuration files**.
This tool allows users to read, modify, and write ROMS input files while preserving the original file structure as much as possible.

The parser is designed for workflows where automated modification of ROMS configuration files is required, such as model experiment management, batch simulation generation, or integration with workflow frameworks.

## Features

* Parse ROMS `.in` configuration files into Python data structures
* Modify parameters programmatically
* Write updated configuration files back to disk
* Preserve the original file layout as much as possible:

  * comments are retained
  * blank lines are retained
  * parameter order is retained
* Support common ROMS input syntax:

  * `=` and `==` parameter assignments
  * line continuation using `\`
  * repeated values using `n*value`
  * logical values `T` and `F`
  * Fortran double precision notation (`1.0d-6`)
  * file lists separated by `|`

## Installation

Clone the repository:

```
git clone https://github.com/yourname/roms-in-parser.git
cd roms-in-parser
```

Install locally:

```
pip install .
```

Or install in editable mode during development:

```
pip install -e .
```

## Usage

### Reading a ROMS `.in` file

```python
from roms_in_parser import ROMSInParser

parser = ROMSInParser("roms_basin.in")
parser.parse()

print(parser["Lm"])
```

### Modifying parameters

```python
parser["Lm"] = 200
parser["DT"] = 60
```

For parameters stored as lists:

```python
parser["Dout(iTsdif)"][0] = False
```

### Writing a new `.in` file

```
parser.write("new_roms.in")
```

Only the parameter values will be updated; other parts of the file will remain unchanged.

## Example

Original configuration:

```
Lm == 180        ! grid size
Mm == 140
```

After modification:

```
parser["Lm"] = 200
parser.write("new_roms.in")
```

Output:

```
Lm == 200        ! grid size
Mm == 140
```

## Supported Value Types

The parser automatically converts values into Python types.

| ROMS syntax | Python type   |      |
| ----------- | ------------- | ---- |
| `10`        | `int`         |      |
| `0.5`       | `float`       |      |
| `1.0d-6`    | `float`       |      |
| `T` / `F`   | `bool`        |      |
| `2*1.0d-6`  | expanded list |      |
| `file1.nc   | file2.nc`     | list |

## Limitations

Some formatting differences may occur when writing files:

* multi-line parameters using `\` may be written as a single line
* `n*value` shorthand is expanded to explicit lists

These changes do not affect ROMS functionality.

## License

GPL-v3 License

## Author

Yupeng Shao
