From 12bff27947f88cfea49cbc28a43f0903feeaf820 Mon Sep 17 00:00:00 2001 From: "Danilo A. Silva" Date: Mon, 3 Jun 2024 16:50:03 -0300 Subject: [PATCH 1/4] removing lhico stuff --- .github/workflows/docker4roms_shelfwaves.yml | 33 -------------------- Dockerfile.shelfwaves | 26 --------------- docker-compose-shelfwaves.yml | 10 ------ 3 files changed, 69 deletions(-) delete mode 100644 .github/workflows/docker4roms_shelfwaves.yml delete mode 100644 Dockerfile.shelfwaves delete mode 100644 docker-compose-shelfwaves.yml diff --git a/.github/workflows/docker4roms_shelfwaves.yml b/.github/workflows/docker4roms_shelfwaves.yml deleted file mode 100644 index 14ce90f..0000000 --- a/.github/workflows/docker4roms_shelfwaves.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Docker Image CI - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - - build: - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v2 - - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_USER }} - password: ${{ secrets.DOCKER_TOKEN }} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Build and push - uses: docker/build-push-action@v2 - with: - context: . - file: ./Dockerfile.shelfwaves - push: true - tags: ${{ secrets.DOCKER_USER }}/docker4roms:shelfwaves diff --git a/Dockerfile.shelfwaves b/Dockerfile.shelfwaves deleted file mode 100644 index 8390fc0..0000000 --- a/Dockerfile.shelfwaves +++ /dev/null @@ -1,26 +0,0 @@ -FROM ubuntu:16.04 -MAINTAINER Danilo A. Silva - -# install dependencies for ROMS -RUN apt-get update && apt-get -y install sudo wget build-essential gfortran && \ - apt-get -y install subversion libnetcdf-dev libnetcdff-dev libhdf5-serial-dev &&\ - apt-get -y install libkernlib1-gfortran netcdf-bin hdf5-tools mpich nano - -# add user lhico with no password, add to sudo group -RUN addgroup --gid 127 docker - -RUN adduser --disabled-password --gecos '' -gid 127 lhico &&\ - adduser lhico sudo &&\ - echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers - -#RUN chown -R lhico:lhico /home/lhico - -USER lhico - -# set a working directory to open when run the container -WORKDIR /home/lhico/ - -# set netcdf4 directories -ENV NF_CONFIG=/usr/bin/nf-config -ENV NETCDF_INCDIR=/usr/include - diff --git a/docker-compose-shelfwaves.yml b/docker-compose-shelfwaves.yml deleted file mode 100644 index 3a3bb51..0000000 --- a/docker-compose-shelfwaves.yml +++ /dev/null @@ -1,10 +0,0 @@ -version: "3" - -services: - roms: - image: nilodna/docker4roms:latest - container_name: roms_user - tty: true - volumes: - - ../src_code:/home/lhico/roms_src - - ../projects:/home/lhico/projects From 6388f5443e9e554669b1dbc4210f38f6245423df Mon Sep 17 00:00:00 2001 From: "Danilo A. Silva" Date: Mon, 3 Jun 2024 16:50:34 -0300 Subject: [PATCH 2/4] adding Dalton as maintainer --- Dockerfile.personal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.personal b/Dockerfile.personal index dfc3c99..6855244 100644 --- a/Dockerfile.personal +++ b/Dockerfile.personal @@ -1,5 +1,5 @@ FROM ubuntu:20.04 -MAINTAINER Danilo A. Silva +MAINTAINER Danilo A. Silva and Dalton K. Sasaki # install dependencies for ROMS RUN apt-get update From c11a14dd38f4a607912f4d72df35d9ab4d43d570 Mon Sep 17 00:00:00 2001 From: "Danilo A. Silva" Date: Mon, 3 Jun 2024 18:38:33 -0300 Subject: [PATCH 3/4] preparing readme and build_roms pre configured for tests --- README.md | 68 +++++------ build_roms.sh | 307 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 335 insertions(+), 40 deletions(-) create mode 100755 build_roms.sh diff --git a/README.md b/README.md index 5f9049f..6fe5742 100644 --- a/README.md +++ b/README.md @@ -38,68 +38,56 @@ docker run -v /path/to/a/shared/folder/projects:/home/lhico/projects -ti docker4 ## Getting started - final user -Close this repository or just download the ```docker-compose-*.yml``` of your preference, but please be aware of the limitations for each setup. +Clone this repository or just download the ```docker-compose-personal.yml```, but please be aware of the limitations for each setup. ### How to run? -After download or clone this repository, access the place where the ```docker-compose-*.yml``` file is and type in your terminal: +After download or clone this repository, access the place where the ```docker-compose-personal.yml``` file is and type in your terminal: -Notice that the following option allows multiple containers from a single image. You can replace `roms_user`, but you should also alter it in `docker-compose-shelfwaves.yml` in the `container_name` field. -``` -docker-compose -f docker-compose-shelfwaves.yml -p roms_user up -d -``` -If you are not using a shared machine, you can simply run: +Notice that the following option allows multiple containers from a single image. You can replace `roms_user`, but you should also alter it in `docker-compose-personal.yml` in the `container_name` field. ``` -docker-compose -f docker-compose-personal.yml up -d +docker-compose -f docker-compose-personal.yml -p roms_user up -d ``` With this command, the docker-compose software will build the right docker4roms release to your case, create two shared folder between host and container, sharing the ROMS source code and your projects setup and put all this to run in background (```-d```). -To access the container, you can type: +Note that the container building process will create two new folders on ```../``` of your structure. These two folders are fundamental to the Docker4ROMS usability, holding the source code of ROMS and your projects (numerical experiments). Make sure to copy the ```build_roms.sh``` file to the projects before accessing the container. -If shelfwaves option is selected: +To access the container, you can type: Again `roms_user` must be the same as in the docker-compose command. ``` docker exec -it roms_user bash ``` -if you are using a personal machine: +and you will access the working directory ```/home/lhico``` with two folders: roms_src and projects. + +## Running my first test case - upwelling + +This repository contains a ```build_roms.sh``` pre configure to be used inside the docker4roms structure. You must copy this file inside your ```projects``` folder and run the following steps for the UPWELLING test case: ``` -docker exec -it roms bash -``` +# access your container: +docker exec -it roms_user bash -and you will access the working directory ```/home/lhico``` with two folders: roms_src and projects. +# Once inside the container, go to projects folder and create a new folder +# note that the build_roms.sh must be in the projects folder. +cd projects; mkdir upwelling +# Now you need to copy the upwelling configuration files, that came with the ROMS source code +cd upwelling +cp ../build_roms.sh . +cp ../../roms_src/ROMS/External/roms_upwelling.in . +cp ../../roms_src/ROMS/External/varinfo.dat . +cp ../../roms_src/ROMS/Include/upwelling.h . -## Running my first test case - upwelling +# compile the model: +sudo bash build_roms.sh -UNDER DEVELOPMENT +# change VARNAME = varinfo.dat in the roms_upwelling.in +nano roms_upwelling.in -``` -Rodando um test case - Compilar o modelo - Para o caso do upwelling (testcase mais conhecido), 3 arquivos são necessários. Estes já estão presentes no ROMS, mas fica cada um numa pasta - dentro da estrutura. - No diretório projects e cria uma pasta lá, pode ser upwelling mesmo - cd projects; mkdir upwelling - cp ../src_code/ROMS/External/roms_upwelling.in . - cp ../roms_src/ROMS/External/varinfo.dat . - cp ../src_code/ROMS/Include/upwelling.h . - cp ../src_code/ROMS/bin/build_roms.bash . - faz esses passos aí dentro da pasta que vc criar pra simulação - aí precisa editar alguns arquivos pra ajustar os caminhos. - editar o build_roms.bash - linha 110: mudar para MY_ROOT_DIR=${HOME}/roms_src - linha 111: mudar para MY_PROJECT_DIR=${HOME}/projects/upwelling - linha 124: mudar para MY_ROMS_SRC=${MY_ROOT_DIR} - linha 173: mudar para FORT=gfortran - linha 177: comentar a linha # export USE_LARGE=on (checar se isso é necessário) - linha 178: descomentar a linha export USE_NETCDF4=on - editar o roms_upwelling.in - linha 76: mudar para VARNAME = varinfo.dat - Rodando o modelo - sudo ./romsS < roms_upwelling.in +# now just run the model: +sudo ./romsS < roms_upwelling.in ``` diff --git a/build_roms.sh b/build_roms.sh new file mode 100755 index 0000000..e2490e9 --- /dev/null +++ b/build_roms.sh @@ -0,0 +1,307 @@ +#!/bin/bash +# +# svn $Id: build_roms.sh 1120 2022-04-08 19:14:36Z arango $ +#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +# Copyright (c) 2002-2022 The ROMS/TOMS Group ::: +# Licensed under a MIT/X style license ::: +# See License_ROMS.txt ::: +#::::::::::::::::::::::::::::::::::::::::::::::::::::: Hernan G. Arango ::: +# ::: +# ROMS Compiling BASH Script ::: +# ::: +# Script to compile an user application where the application-specific ::: +# files are kept separate from the ROMS source code. ::: +# ::: +# Q: How/why does this script work? ::: +# ::: +# A: The ROMS makefile configures user-defined options with a set of ::: +# flags such as ROMS_APPLICATION. Browse the makefile to see these. ::: +# If an option in the makefile uses the syntax ?= in setting the ::: +# default, this means that make will check whether an environment ::: +# variable by that name is set in the shell that calls make. If so ::: +# the environment variable value overrides the default (and the ::: +# user need not maintain separate makefiles, or frequently edit ::: +# the makefile, to run separate applications). ::: +# ::: +# Usage: ::: +# ::: +# ./build_roms.sh [options] ::: +# ::: +# Options: ::: +# ::: +# -j [N] Compile in parallel using N CPUs ::: +# omit argument for all available CPUs ::: +# ::: +# -p macro Prints any Makefile macro value. For example, ::: +# ::: +# build_roms.sh -p FFLAGS ::: +# ::: +# -noclean Do not clean already compiled objects ::: +# ::: +# Notice that sometimes the parallel compilation fail to find MPI ::: +# include file "mpif.h". ::: +# ::: +#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +export which_MPI=openmpi # default, overwritten below + +parallel=0 +clean=1 +dprint=0 + +export MY_CPP_FLAGS=${MY_CPP_FLAGS} + +while [ $# -gt 0 ] +do + case "$1" in + -j ) + shift + parallel=1 + test=`echo $1 | grep '^[0-9]\+$'` + if [ "$test" != "" ]; then + NCPUS="-j $1" + shift + else + NCPUS="-j" + fi + ;; + + -p ) + shift + clean=0 + dprint=1 + debug="print-$1" + shift + ;; + + -noclean ) + shift + clean=0 + ;; + + * ) + echo "" + echo "$0 : Unknown option [ $1 ]" + echo "" + echo "Available Options:" + echo "" + echo "-j [N] Compile in parallel using N CPUs" + echo " omit argument for all avaliable CPUs" + echo "" + echo "-p macro Prints any Makefile macro value" + echo " For example: build_roms.sh -p FFLAGS" + echo "" + echo "-noclean Do not clean already compiled objects" + echo "" + exit 1 + ;; + esac +done + +# Set the CPP option defining the particular application. This will +# determine the name of the ".h" header file with the application +# CPP definitions. + +export ROMS_APPLICATION=UPWELLING + +# Set a local environmental variable to define the path to the directories +# where all this project's files are kept. + +export MY_ROOT_DIR=${HOME}/roms_src +export MY_PROJECT_DIR=${PWD} + +# The path to the user's local current ROMS source code. +# +# If using svn locally, this would be the user's Working Copy Path (WCPATH). +# Note that one advantage of maintaining your source code locally with svn +# is that when working simultaneously on multiple machines (e.g. a local +# workstation, a local cluster and a remote supercomputer) you can checkout +# the latest release and always get an up-to-date customized source on each +# machine. This script is designed to more easily allow for differing paths +# to the code and inputs on differing machines. + + export MY_ROMS_SRC=${MY_ROOT_DIR} + +# Set path of the directory containing makefile configuration (*.mk) files. +# The user has the option to specify a customized version of these files +# in a different directory than the one distributed with the source code, +# ${MY_ROMS_SRC}/Compilers. If this is the case, you need to keep these +# configurations files up-to-date. + + export COMPILERS=${MY_ROMS_SRC}/Compilers +#export COMPILERS=${HOME}/Compilers/ROMS + +#-------------------------------------------------------------------------- +# Set tunable CPP options. +#-------------------------------------------------------------------------- +# +# Sometimes it is desirable to activate one or more CPP options to run +# different variants of the same application without modifying its header +# file. If this is the case, specify each options here using the -D syntax. +# Notice also that you need to use shell's quoting syntax to enclose the +# definition. Both single or double quotes work. For example, +# +#export MY_CPP_FLAGS="${MY_CPP_FLAGS} -DAVERAGES" +#export MY_CPP_FLAGS="${MY_CPP_FLAGS} -DDEBUGGING" +# +# can be used to write time-averaged fields. Notice that you can have as +# many definitions as you want by appending values. + +#export MY_CPP_FLAGS="${MY_CPP_FLAGS} -D" + +#-------------------------------------------------------------------------- +# Compiler options. +#-------------------------------------------------------------------------- +# +# Other user defined environmental variables. See the ROMS makefile for +# details on other options the user might want to set here. Be sure to +# leave the switches meant to be off set to an empty string or commented +# out. Any string value (including off) will evaluate to TRUE in +# conditional if-statements. + +#export USE_MPI=on # distributed-memory parallelism +#export USE_MPIF90=on # compile with mpif90 script +#export which_MPI=intel # compile with mpiifort library +#export which_MPI=mpich # compile with MPICH library +#export which_MPI=mpich2 # compile with MPICH2 library +#export which_MPI=mvapich2 # compile with MVAPICH2 library +#export which_MPI=openmpi # compile with OpenMPI library + +#export USE_OpenMP=on # shared-memory parallelism + +# export FORT=ifort +export FORT=gfortran +#export FORT=pgi + +#export USE_DEBUG=on # use Fortran debugging flags +# export USE_LARGE=on # activate 64-bit compilation + +#-------------------------------------------------------------------------- +# Building the ROMS executable using the shared library is not recommended +# because it requires keeping track of the matching libROMS.{so|dylib} +# which is located in the Build_roms or Build_romsG directory and will be +# lost and/or replaced with each new build. The option to build the shared +# version of libROMS was introduced for use in model coupling systems. +#-------------------------------------------------------------------------- + +#export SHARED=on # build libROMS.{so|dylib} + export STATIC=on # build libROMS.a + + export EXEC=on # build roms{G|M|O|S} executable + +# ROMS I/O choices and combinations. A more complete description of the +# available options can be found in the wiki (https://myroms.org/wiki/IO). +# Most users will want to enable at least USE_NETCDF4 because that will +# instruct the ROMS build system to use nf-config to determine the +# necessary libraries and paths to link into the ROMS executable. + + export USE_NETCDF4=on # compile with NetCDF-4 library +#export USE_PARALLEL_IO=on # Parallel I/O with NetCDF-4/HDF5 +#export USE_PIO=on # Parallel I/O with PIO library +#export USE_SCORPIO=on # Parallel I/O with SCORPIO library + +# If any of the coupling component use the HDF5 Fortran API for primary +# I/O, we need to compile the main driver with the HDF5 library. + +#export USE_HDF5=on # compile with HDF5 library + +#-------------------------------------------------------------------------- +# If coupling Earth System Models (ESM), set the location of the ESM +# component libraries and modules. The strategy is to compile and link +# each ESM component separately first, and then ROMS since it is driving +# the coupled system. Only the ESM components activated are considered +# and the rest are ignored. Some components like WRF cannot be built +# in a directory specified by the user but in its own root directory, +# and cannot be moved when debugging with tools like TotalView. +#-------------------------------------------------------------------------- + +export WRF_SRC_DIR=${HOME}/ocean/repository/WRF + +if [ -n "${USE_DEBUG:+1}" ]; then + export CICE_LIB_DIR=${MY_PROJECT_DIR}/Build_ciceG + export COAMPS_LIB_DIR=${MY_PROJECT_DIR}/Build_coampsG + export REGCM_LIB_DIR=${MY_PROJECT_DIR}/Build_regcmG + export WAM_LIB_DIR=${MY_PROJECT_DIR}/Build_wamG +# export WRF_LIB_DIR=${MY_PROJECT_DIR}/Build_wrfG + export WRF_LIB_DIR=${WRF_SRC_DIR} +else + export CICE_LIB_DIR=${MY_PROJECT_DIR}/Build_cice + export COAMPS_LIB_DIR=${MY_PROJECT_DIR}/Build_coamps + export REGCM_LIB_DIR=${MY_PROJECT_DIR}/Build_regcm + export WAM_LIB_DIR=${MY_PROJECT_DIR}/Build_wam + export WRF_LIB_DIR=${MY_PROJECT_DIR}/Build_wrf +# export WRF_LIB_DIR=${WRF_SRC_DIR} +fi + +#-------------------------------------------------------------------------- +# If applicable, use my specified library paths. +#-------------------------------------------------------------------------- + + export USE_MY_LIBS=no # use system default library paths +#export USE_MY_LIBS=yes # use my customized library paths + +MY_PATHS=${COMPILERS}/my_build_paths.sh + +if [ "${USE_MY_LIBS}" == "yes" ]; then + source ${MY_PATHS} ${MY_PATHS} +fi + +#-------------------------------------------------------------------------- +# The rest of this script sets the path to the users header file and +# analytical source files, if any. See the templates in User/Functionals. +#-------------------------------------------------------------------------- +# +# If applicable, use the MY_ANALYTICAL_DIR directory to place your +# customized biology model header file (like fennel.h, nemuro.h, ecosim.h, +# etc). + + export MY_HEADER_DIR=${MY_PROJECT_DIR} + + export MY_ANALYTICAL_DIR=${MY_PROJECT_DIR}/functionals + +# Put the binary to execute in the following directory. + + export BINDIR=${MY_PROJECT_DIR} + +# Put the f90 files in a project specific Build directory to avoid conflict +# with other projects. + +if [ -n "${USE_DEBUG:+1}" ]; then + export SCRATCH_DIR=${MY_PROJECT_DIR}/Build_romsG +else + export SCRATCH_DIR=${MY_PROJECT_DIR}/Build_roms +fi + +# Go to the users source directory to compile. The options set above will +# pick up the application-specific code from the appropriate place. + + cd ${MY_ROMS_SRC} + +# Stop if activating both MPI and OpenMP at the same time. + +if [ -n "${USE_MPI:+1}" ] && [ -n "${USE_OpenMP:+1}" ]; then + echo "You cannot activate USE_MPI and USE_OpenMP at the same time!" + exit 1 +fi + +#-------------------------------------------------------------------------- +# Compile. +#-------------------------------------------------------------------------- + +# Remove build directory. + +if [ $clean -eq 1 ]; then + make clean +fi + +# Compile (the binary will go to BINDIR set above). + +if [ $dprint -eq 1 ]; then + make $debug +else + if [ $parallel -eq 1 ]; then + make $NCPUS + else + make + fi +fi From d5cfbde088a8ede65bcd4d9ad7162d5b33e868bc Mon Sep 17 00:00:00 2001 From: "Danilo A. Silva" Date: Tue, 4 Jun 2024 22:03:53 -0300 Subject: [PATCH 4/4] adjust tutorial --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6fe5742..72ffa08 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,19 @@ and you will access the working directory ```/home/lhico``` with two folders: ro This repository contains a ```build_roms.sh``` pre configure to be used inside the docker4roms structure. You must copy this file inside your ```projects``` folder and run the following steps for the UPWELLING test case: ``` -# access your container: +# outside the container, first follow this sequence of codes: +cd ../projects +mkdir upwelling # create new folder for our test +chmod 777 upwelling # give full writing and reading privileges +cd upwelling + +# copy files for the UPWELLING test case +cp ../../docker-roms/build_roms.sh . +cp ../../src_code/ROMS/External/roms_upwelling.in . +cp ../../src_code/ROMS/External/varinfo.yaml . +cp ../../src_code/ROMS/Include/upwelling.h . + +# Now, access your container: docker exec -it roms_user bash # Once inside the container, go to projects folder and create a new folder