Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3222100
first commit into Multivariate branch: start adapting code to multiva…
pdicerbo Jun 26, 2017
3aecdf6
now the code compiles -> start working
pdicerbo Jun 27, 2017
bce96ae
tmp commit: multivariate cost function partially adapted, only observ…
pdicerbo Jun 28, 2017
7f9937a
all things should work well; only output missing
pdicerbo Jun 28, 2017
bd4877c
fixing "important" bug and adding check on the tao solution status
pdicerbo Jun 28, 2017
298a862
fixing some bugs and leaving to Milan....
pdicerbo Jun 29, 2017
908221a
First attempt nutrient DA for coupling with ogstm
Jan 19, 2018
bc55828
Implemented update of N1p with assimilation of N3n reading file of co…
Jan 19, 2018
743a108
Some problems resolved. Running version BUT N1p update not yet working
Jan 24, 2018
f46f4e1
Removed problems for N1p update
Jan 25, 2018
34ee72b
Synchronizing with gitlab 4.0
Nov 24, 2021
9797453
Syncronizing with Release-4.1
Feb 11, 2025
7be2221
Adapting to petsc/3.20.1 on leonardo, included in Intel Suite 2023.
Feb 11, 2025
75a979c
Fix default lib and include path
pogmat Mar 11, 2025
50aea5c
fix type of variable
japs Mar 12, 2025
dd43047
simplify makefile
japs Mar 13, 2025
353949d
only use one compiler instead of 4
japs Mar 13, 2025
a1f67d0
conditional assignment of env
japs Mar 13, 2025
3ee47af
remove useless rules
japs Mar 13, 2025
b116896
pruning
japs Mar 13, 2025
e7ff84c
phony
japs Mar 13, 2025
b59a60a
use flat dir structure
japs Mar 13, 2025
a72ba2a
Remove space in sed expression.
pogmat Mar 28, 2025
60e2a7a
Fix regexp in sed.
pogmat Mar 28, 2025
43ea7a9
Add $ in sed regex.
pogmat Mar 28, 2025
32a33e9
Rephrase regex in sed.
pogmat Mar 28, 2025
3487935
Back to previous expression.
pogmat Mar 28, 2025
a343b15
Use --keep-system-cflags
pogmat Mar 28, 2025
88844cb
Remove sed.
pogmat Mar 28, 2025
af52221
New excape character
pogmat Mar 28, 2025
786535a
add needed rpath to executable
Apr 2, 2025
be11ada
keep system flags
japs Nov 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 63 additions & 44 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ SHELL = /bin/sh
############################################################################
#
# Copyright 2006 Srdjan Dobricic, CMCC, Bologna
# Copyright 2025 Jacopo Nespolo, Matteo Poggi, eXact lab S.r.l, Trieste
#
# This file is part of OceanVar.
#
Expand All @@ -24,19 +25,6 @@ SHELL = /bin/sh
#
############################################################################

include compiler.inc

ifndef NETCDF_INC
export NETCDF_INC=/usr/include
endif

ifndef NETCDF_LIB
export NETCDF_LIB=/usr/lib
endif
$(info $$NETCDF_INC = ${NETCDF_INC})
$(info $$NETCDF_LIB = ${NETCDF_LIB})
$(info $$LIBNCMEDLEV = ${LIBNCMEDLEV})

EXEC = var_3d
LIB = libvar_3d.a

Expand All @@ -49,7 +37,7 @@ KNDSTR = \
set_knd.o
OBJSTR = \
filename_mod.o\
da_params.o\
da_params.o\
drv_str.o\
cns_str.o\
obs_str.o\
Expand Down Expand Up @@ -100,11 +88,15 @@ PHYSOBS = \

OBJS = \
def_nml.o\
def_nml_multi.o\
def_grd.o\
sav_itr.o\
rdeofs.o\
rdrcorr.o\
mean_rdr.o\
rdeofs_chl.o\
rdeofs_n3n.o\
rdeofs_o2o.o\
rdeofs_multi.o\
rdrcorr.o\
mean_rdr.o\
netcdf_err.o\
get_obs.o\
get_obs_arg.o\
Expand All @@ -113,18 +105,23 @@ OBJS = \
obs_vec.o\
ini_cfn.o\
cnv_ctv.o\
ver_hor.o\
ver_hor_chl.o\
ver_hor_nut.o\
rcfl_x.o\
rcfl_y.o\
veof.o\
veof_chl.o\
veof_nut.o\
obsop.o\
obs_arg.o\
resid.o\
res_inc.o\
obsop_ad.o\
obs_arg_ad.o\
veof_ad.o\
ver_hor_ad.o\
veof_chl_ad.o\
veof_nut_ad.o\
veof_multiv_ad.o\
ver_hor_chl_ad.o\
ver_hor_nut_ad.o\
rcfl_x_ad.o\
rcfl_y_ad.o\
rcfl_y_ad_init.o\
Expand All @@ -137,8 +134,17 @@ OBJS = \
readAnisotropy.o\
bio_mod.o\
bio_mod_ad.o\
readBioStat.o\
wrt_bio_stat.o\
readChlStat.o\
readNutStat.o\
readNutCov.o\
readChlNutCov.o\
wrt_chl_stat.o\
wrt_upd_nut.o\
wrt_nut_stat.o\
wrt_o2o_stat.o\
cp_chl_stat.o\
cp_nut_stat.o\
cp_o2o_stat.o\
costf.o\
obs_sat.o\
bio_conv.o\
Expand All @@ -147,15 +153,41 @@ OBJS = \
readGrid.o\
def_cov.o\
tao_minimizer.o\
oceanvar.o
oceanvar.o

MAINEXE = main.o

# needed libraries
depends = petsc netcdf netcdf-fortran pnetcdf

# NOTE: It may happen that pkg-config returns a spurious `-I`. We pass the
# string through sed to sanitise.
INCLUDE_FLAGS ?= \
$(shell pkg-config --cflags --keep-system-cflags $(depends) | sed -E 's/-I(\s+|$$)//g')

# set rpath in the binary, required in order to find the correct libs at runtime.
# Env modules nowadays do not pollute the env with LD_LIBRARY_PATH, for good reason.
LDFLAGS ?= \
$(shell pkg-config --libs $(depends)) \
-Wl,-rpath -Wl,$(shell pkg-config --libs-only-L $(depends) |sed 's/-L//' |sed 's/-L/:/g' |sed 's/ //g')

FFLAGS ?= -O2 -ffree-line-length-none -c
FC ?= mpif90
LD ?= mpif90

$(info $$INCLUDE_FLAGS = ${INCLUDE_FLAGS})
$(info $$FFLAGS = ${FFLAGS})
$(info $$LDFLAGS = ${LDFLAGS})
$(info $$FC = ${FC})
$(info $$LD = ${LD})

.SUFFIXES: .f90

.PHONY:all
all: $(EXEC) $(LIB)
@echo $(EXEC) is compiled

.PHONY:install
install: $(EXEC)
cp -p $(EXEC) $(INSTDIR)

Expand All @@ -165,31 +197,18 @@ $(EXEC) : $(LIBDEP) $(KNDSTR) $(OBJSTR) $(OBJS) $(MAINEXE)
$(LIB) : $(KNDSTR) $(OBJSTR) $(OBJS)
ar -r $(LIB) $(KNDSTR) $(OBJSTR) $(OBJS)

tao_minimizer.o: tao_minimizer.f90
$(CPP) -I$(PETSC_INC) $*.f90 > cpp.$*.f90 ; $(F90) -I$(PETSC_INC) $(FFLAGS) cpp.$*.f90 ; $(MV) cpp.$*.o $*.o

mpi_utils.o: mpi_utils.f90
$(CPP) -I$(PETSC_INC) $*.f90 > cpp.$*.f90 ; $(F90) -I$(PETSC_INC) $(FFLAGS) cpp.$*.f90 ; $(MV) cpp.$*.o $*.o

.DEFAULTS:
.f90.o :
$(CPP) $*.f90 > cpp.$*.f90 ; $(F90) $(FFLAGS) cpp.$*.f90 ; $(MV) cpp.$*.o $*.o

.f.o :
$(CPP) $*.f > cpp.$*.f ; $(F77) $(FFLAGS) cpp.$*.f ; $(MV) cpp.$*.o $*.o

libf_exit.a :
cd $(LIBFEXIT) && $(MAKE)
$(FC) -cpp $(INCLUDE_FLAGS) $(FFLAGS) -o $@ $*.f90

libnc-medlevel.a :
cd $(LIBNCMEDLEV) && $(MAKE)
libnc-medlevel.a : nc-med-level-lib.o
$(AR) cr $@ $<

.PHONY:clean
clean:
$(RM) *.o *.mod cpp.* *.L
cd $(LIBNCMEDLEV) && $(MAKE) erase
cd ..
$(RM) *.o *.mod cpp.* *.L *.a
$(RM) libnc-medlevel/*.a libnc-medlevel/*.o

.PHONY:erease
erase:
$(RM) *.o *.mod cpp.* *.L $(EXEC)
cd $(LIBNCMEDLEV) && $(MAKE) erase
cd ..
10 changes: 8 additions & 2 deletions bio_conv.f90
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,22 @@ subroutine bio_conv
!-----------------------------------------------------------------------

use grd_str
use eof_str
use bio_str
use drv_str

implicit none

INTEGER(i4) :: i, j, k, l
INTEGER(i4) :: i, j, k, l, my_km

grd%chl(:,:,:) = 0.0

my_km = grd%km
if(drv%multiv.eq.1) &
my_km = ros%kmchl

do l = 1,bio%nphy
do k = 1,grd%km
do k = 1,my_km
do j = 1,grd%jm
do i = 1,grd%im
grd%chl(i,j,k) = grd%chl(i,j,k) + bio%phy(i,j,k,l,1)
Expand Down
10 changes: 8 additions & 2 deletions bio_conv_ad.f90
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,22 @@ subroutine bio_conv_ad
!-----------------------------------------------------------------------

use grd_str
use eof_str
use bio_str
use drv_str

implicit none

INTEGER(i4) :: i, j, k, l
INTEGER(i4) :: i, j, k, l, my_km

bio%phy_ad(:,:,:,:,:) = 0.0

my_km = grd%km
if(drv%multiv .eq. 1) &
my_km = ros%kmchl

do l = 1,bio%nphy
do k = 1,grd%km
do k = 1,my_km
do j = 1,grd%jm
do i = 1,grd%im
bio%phy_ad(i,j,k,l,1) = bio%phy_ad(i,j,k,l,1) + grd%chl_ad(i,j,k)
Expand Down
9 changes: 7 additions & 2 deletions bio_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,21 @@ subroutine bio_mod
use grd_str
use bio_str
use eof_str
use drv_str

IMPLICIT NONE

INTEGER(i4) :: m, l, k,j ,i
INTEGER(i4) :: m, l, k,j ,i, my_km

bio%phy(:,:,:,:,:) = 0.0

my_km = grd%km
if(drv%multiv .eq. 1) &
my_km = ros%kmchl

do m=1,bio%ncmp
do l=1,bio%nphy
do k=1,grd%km
do k=1,my_km
do j=1,grd%jm
do i=1,grd%im
bio%phy(i,j,k,l,m)=bio%cquot(i,j,k,l,m)*bio%pquot(i,j,k,l)*grd%chl(i,j,k)
Expand Down
9 changes: 7 additions & 2 deletions bio_mod_ad.f90
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,21 @@ subroutine bio_mod_ad
use grd_str
use bio_str
use eof_str
use drv_str

IMPLICIT NONE

INTEGER(i4) :: m, l, k, j, i
INTEGER(i4) :: m, l, k, j, i, my_km

grd%chl_ad(:,:,:) = 0.0

my_km = grd%km
if(drv%multiv .eq. 1) &
my_km = ros%kmchl

do m=1,bio%ncmp
do l=1,bio%nphy
do k=1,grd%km
do k=1,my_km
do j=1,grd%jm
do i=1,grd%im
grd%chl_ad(i,j,k) = grd%chl_ad(i,j,k) + bio%cquot(i,j,k,l,m) * bio%pquot(i,j,k,l) * bio%phy_ad(i,j,k,l,m)
Expand Down
14 changes: 11 additions & 3 deletions bio_str.f90
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,21 @@ MODULE bio_str
REAL(r8), POINTER :: pquot(:,:,:,:) ! Phytoplankton component quotas
REAL(r8), POINTER :: phy(:,:,:,:,:) ! biogeochemical variables
REAL(r8), POINTER :: phy_ad(:,:,:,:,:) ! biogeochemical adjoint variables
REAL(r8), POINTER :: InitialChl(:,:,:) ! initial amount of chlorophyll
REAL(r8), POINTER :: InitialChl(:,:,:) ! initial amount of chlorophyll
REAL(r8), POINTER :: InitialNut(:,:,:,:) ! initial amount of nutrients
REAL(r8), POINTER :: covn3n_n1p(:,:,:) ! covariance n3n n1p
REAL(r8), POINTER :: covn3n_chl(:,:,:) ! covariance n3n chl
REAL(r8), POINTER :: covn1p_chl(:,:,:) ! covariance n3n chl

INTEGER :: nphy ! number of phytoplankton types
INTEGER :: ncmp ! No. of phytoplankton components

LOGICAL :: ApplyConditions ! Apply conditions in snutell operations

LOGICAL :: ApplyConditions ! Apply conditions in snutell operations

INTEGER(i4) :: N3n ! N3n assimilation
INTEGER(i4) :: updateN1p ! N1p update based on N3n assimilation
INTEGER(i4) :: O2o ! O2o assimilation

END TYPE bio_t

TYPE (bio_t) :: bio
Expand Down
6 changes: 6 additions & 0 deletions clean_mem.f90
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ subroutine clean_mem
DEALLOCATE ( arg%ib, arg%jb, arg%kb)
DEALLOCATE ( arg%pq1, arg%pq2, arg%pq3, arg%pq4)
DEALLOCATE ( arg%pq5, arg%pq6, arg%pq7, arg%pq8)
DEALLOCATE ( arg%par)
DEALLOCATE (grd%lon, grd%lat)
endif

Expand All @@ -72,11 +73,16 @@ subroutine clean_mem
DEALLOCATE ( rcf%sc)

DEALLOCATE(SendCountX3D, SendDisplX3D)
DEALLOCATE(SendCountX3D_chl, SendDisplX3D_chl)
DEALLOCATE(RecCountX3D, RecDisplX3D)
DEALLOCATE(RecCountX3D_chl, RecDisplX3D_chl)

DEALLOCATE(ChlExtended)
DEALLOCATE(ChlExtended_3d,N3nExtended_3d,O2oExtended_3d)
DEALLOCATE(SendBottom, RecTop)
DEALLOCATE(SendTop, RecBottom)
DEALLOCATE(SendTop_2d, RecBottom_2d)
DEALLOCATE(SendBottom_2d, RecTop_2d)

if(MyId .eq. 0) then
write(*,*) ' ALL MEMORY CLEAN'
Expand Down
27 changes: 25 additions & 2 deletions cnv_inn.f90
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,36 @@ subroutine cnv_inn
use eof_str
use ctl_str
use drv_str
use bio_str

implicit none

! --------
! Convert the control vector to v
call cnv_ctv

call ver_hor

if (drv%multiv .eq. 0) then
if(drv%chl_assim .eq. 1) then
call ver_hor_chl
endif
if(drv%nut .eq. 1) then
if(bio%N3n .eq. 1) then
call ver_hor_nut(grd%n3n, grd%n3n_ad,'N')
endif
if(bio%O2o .eq. 1) then
call ver_hor_nut(grd%o2o, grd%o2o_ad,'O')
endif
endif
endif

if (drv%multiv .eq. 1) then
call ver_hor_chl
call ver_hor_nut(grd%n3n, grd%n3n_ad,'N')
endif

! ---
! Apply biological repartition of the chlorophyll
if((drv%chl_assim .eq. 1) .or. (drv%multiv .eq. 1)) &
call bio_mod

end subroutine cnv_inn
Loading