case.setup is a script in CIMEROOT/CIME/Tools.

$ ./case.setup --help
usage: case.setup [-h] [-d] [-v] [-s] [-c] [-t] [-r] [-k KEEP] [-N] [caseroot]

Creates various files and directories needed in order to build the case,
create namelists and run the case.

Any changes to env_mach_pes.xml and env_mach_specific.xml must be made
before running this.

This must be run before running

To run this initially for the case, simply run:

To rerun after making changes to env_mach_pes.xml or env_mach_specific.xml, run:
   ./case.setup --reset

positional arguments:
  caseroot              Case directory to setup.
                        Default is current directory.

  -h, --help            show this help message and exit
  -d, --debug           Print debug information (very verbose) to file /home/runner/work/cime/cime/CIME/Tools/case.setup.log
  -v, --verbose         Add additional context (time and file) to log messages
  -s, --silent          Print only warnings and error messages
  -c, --clean           Removes the batch run script for target machine.
                        If the testmode argument is present then keep the test
                        script if it is present - otherwise remove it.
                        The user_nl_xxx and Macros files are never removed by case.setup -
                        you must remove them manually.
  -t, --test-mode       Keeps the test script when the --clean argument is used.
  -r, --reset           Does a clean followed by setup.
                        This flag should be used when rerunning case.setup after it
                        has already been run for this case.
  -k KEEP, --keep KEEP  When cleaning/resetting a case, do not remove/refresh files in this list. Choices are batch script, env_mach_specific.xml, Macros.make, Macros.cmake. Use should use this if you have local modifications to these files that you want to keep.
  -N, --non-local       Use when you've requested a machine that you aren't on. Will reduce errors for missing directories etc.