ESCOMP / ESCOMP/CTSM

From '/glade/scratch' to '/glade/derecho/scratch'

Open
#2,650 4 comments 0 reactions 0 assignees View on GitHub
b4b bug good first issue test: none
Dominant language
Fortran
Stars
352
Forks
361
Avg merge
6d 6h
Merged PRs (30d)
8

Description

**Bug Subject:**
As NCAR supercomputer users: From '/glade/scratch' to '/glade/derecho/scratch'

**Bug Content:**

### Brief summary of bug

As shown in [NCAR HPC Docs](https://ncar-hpc-docs.readthedocs.io/en/latest/storage-systems/glade/#overview), `/glade/scratch/username` no longer exists. The new scratch path is `/glade/derecho/scratch/username`. However, there is a hard-coded `/glade/scratch/username` path in certain CTSM modules, making it difficult to run CTSM successfully.

### General bug information

**CTSM version you are using:** ctsm5.2.010

**Does this bug cause significantly incorrect results in the model's science?** Yes

**Configurations affected:** Yes

### Important details of your setup / configuration so we can reproduce the bug

Run this on NCAR Derecho/Casper supercomputer.

- **Compset:** I2000Clm60FatesSpRsGs
- **Resolution:** f45_g37
- **Machine:** NCAR Derecho/Casper
- **Compiler:** Not sure
- **XML or namelist changes:** None

### Important output or errors that show the problem

wukoutian@casper20:~/clm_tutorial_cases/I2000_CTSM_FATESsp> ./case.setup
Setting resource.RLIMIT_STACK to -1 from (8388608, -1)
job is case.run USER_REQUESTED_WALLTIME None USER_REQUESTED_QUEUE None WALLTIME_FORMAT %H:%M:%S
Creating batch scripts
Writing case.run script from input template /glade/u/home/wukoutian/CTSM/ccs_config/machines/template.case.run
Creating file .case.run
Writing case.st_archive script from input template /glade/u/home/wukoutian/CTSM/ccs_config/machines/template.st_archive
Creating file case.st_archive
Creating user_nl_xxx files for components and cpl
ERROR: Could not make directory '/glade/scratch/wukoutian/I2000_CTSM_FATESsp/bld/cpl/obj', error: [Errno 13] Permission denied: '/glade/scratch'

**How to fix the bug**

For your reference, this bug might have been noticed and partially fixed, as shown in the code search for `scratch`:
https://github.com/search?q=repo%3AESCOMP%2FCTSM%20scratch&type=code

You may also want to also fix all the code related to the retired NCAR `Cheyenne` supercomputer:
https://github.com/search?q=repo%3AESCOMP%2FCTSM%20cheyenne&type=code

When writing commands or scripts, you can use the environment variable `$SCRATCH` to represent your scratch directory. Here are examples for both a command line and a Python script.

### Command Line Example
In a command line script, you can use `$SCRATCH` directly. For example, if you want to list the contents of your scratch directory, you can use:

```bash
ls $SCRATCH
```

Or, if you want to copy a file to your scratch directory:

```bash
cp myfile.txt $SCRATCH/
```

### Python Script Example
In a Python script, you can access the `$SCRATCH` environment variable using the `os` module. Here's an example of how you can do this:

```python
import os

# Get the path to the scratch directory from the environment variable
scratch_dir = os.getenv('SCRATCH')

# Use the scratch directory path in your script
if scratch_dir:
print(f"Scratch directory: {scratch_dir}")

# Example: creating a file in the scratch directory
file_path = os.path.join(scratch_dir, 'myfile.txt')
with open(file_path, 'w') as f:
f.write("This is a test file in the scratch directory.")

print(f"File created at: {file_path}")
else:
print("SCRATCH environment variable is not set.")
```

This script retrieves the path of the scratch directory from the `SCRATCH` environment variable and then uses it to create a file in that directory.

By using the `$SCRATCH` variable, you ensure that your scripts and commands are flexible and can adapt to different environments where the actual path of the scratch directory might vary.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.