Issue with time varying river BGC tracer reading

Hi,

I’m experiencing an issue at present with CROCO-PISCES coupled. Running CROCO alone doesn’t cause an issue with river data reading (time varying T/S are read fine and model runs fine). However, when I turn on PISCES, it seems the code trips on an issue reading BGC tracers for the river.

I have NO3_trc, DIC_trc, PO4_trc and Si_trc in my runoff file. I didn’t have this issue when my river file previously only had T, S and NO3, but I don’t want to revert to that option as it is less realistic.
I have narrowed down the source of the error to /OCEAN/init_scalars.F and /OCEAN/get_psource_ts.F
Specifically, in get_psource_ts.F, in this block of code:
if (got_tsrc(itrc)) then
lvar=lenstr(vname(1,indxTsrc+itrc-1))
ierr=nf_inq_varid (ncidqbar,vname(1,indxTsrc+itrc-1)
& (1:lvar),tsrc_id(itrc))
if (ierr .eq. nf_noerr) then
ierr=nf_inq_varndims (ncidqbar,tsrc_id(itrc), i)
endif
if (ierr .ne. nf_noerr) then
write(stdout,3) vname(1,indxTsrc+itrc-1)(1:lvar),
& qbarname(1:lstr)

I get an error because the way vname for the river tracers is dynamically derived from the main PISCES vars (DIC, TALK,…) in init_scalars.F introduces a repeated “null character” which is printed to screen as ^@
See the error below:

GET_PSOURCE_TS - unable to find forcing variable: NO3_src ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^$
in runoff NetCDF file: croco_runoff.nc–> analytical value (in analytical.F)

The issue only occurs with the 25th of 26 tracers (NO3) but it seems that the code doesn’t even try to look for NH4 either.

I’m tempted to hard code the vname params for the rivers in init_scalars to get past this issue, but I can’t understand why I’m having this issue as other people must have run their rivers for PISCES similarly to me, before now.

Would it help if I had all 26 tracers (T, S and PISCES vars (24)) from the rivers? Could it be an error introduced by ifort?

All suggestions would be greatly appreciated.

I tried many things with this today, and found the solution, which is to increase the size of vname in ncscrum.h from vname(20,500) to vname(20,510)

Hi Jmcgovern,

I am trying to configure something very similar to your setup but I am struggling. I made a forum request if anyone has an example and/or instructions here: https://forum.croco-ocean.org/question/1003/realistic-coastal-pisces-scenario-configuration-documentation/

But since you have done this already, could you please share, if possible, your CONFIG folder for this scenario with bgc tracers from a river?

Thank you for your help
Konstantinos

Can you outline your case study? Location, resolution etc.? Share your struggles on here and I’ll be glad to answer as best I can.

Hi,
Indeed this problem has been identified and fixed increasing the size of vname with vname(20,800).
I assume you are using the official v1.3, as a tarball or the tag v1.3 from release branch.

If you have acces to our gitlab [ https://gitlab.inria.fr/croco-ocean/] , it can be useful to have a look in the evolving branch bugfix_vx.x, [ with x.x the tag number], to see recent bug fix.

Regards,

Hi Gildas,

Thanks for the update. I have been using v1.3 since its release. I’m trying to find out what is Konstantinos’ issue with CROCO for us to assist.

Regards

Hi Joe,

Thank you for your reply. Basically I am trying to learn CROCO-PISCES and I am using the “standard” BENGUELA configuration (low resolution). I have created a croco_runoff.nc file with several nutrients (see attached figure). When I run CROCO by itself, with PSOURCE_NCFILE_TS option, it runs fine. Also when I run CROCO-PISCES without the river PSOURCE it also runs fine. But when I define BIOLOGY and PSOURCE it gives me an error: "1 Number of point sources

READ_INP ERROR while reading block with keyword ‘psource’.
"
Unfortunately, there is no more info given in the croco.out file… CROCO-PISCES would give me the same error even if I run a constant flow PSOURCE river with only temp and salt and no nutrients. Basically doesn’t like any river input.

Thank you for any help.
Konstantinos
image description

This error is referring to the psource block in your croco.in file. I think what you need is to have the correct number of columns of tracer values in the block at the end of the file.

I will see if I can dig out an example for you

Thank you for the suggestion. This is the procedure I am following in case you can spot any errors:

  1. Set ‘makepisces = 1’ in crocotools_param file.
  2. After I have created all the croco required files, (bry, ini, grid etc) I run ‘make_runoff.m’, with option ‘psource_ncfile_ts = 1’ and since ‘makepisces’ is selected, the script automatically create the ‘croco_runoff.nc’ with NO3_src data included in the netcdf.
    The runoff script suggests the following entry:
    psource_ncfile: Nsrc Isrc Jsrc Dsrc qbardir Lsrc Tsrc runoff file name
    CROCO_FILES/croco_runoff.nc
    1
    25 35 0 -1 T T 15.9 25.0202

I also tried with:
25 35 0 -1 T T T 15.9 25.0202 2.9
since the croco_runoff.nc includes the NO3_src with initial value 2.9 but still I get the same error.

I have also changed the setting in the ‘namelist_pisces_ref’ file:
ln_river = .true. ! boolean for river input of nutrients

And I run the ‘make_biol’ script to create the initial and forcing files for pisces.

Yes, it would be great if you could send me an example file, and if you can include the other configuration text files like: cppdefs.h, param.h, croco.in, namelist_pisces_ref, and any other files you needed to edit to make it work.

Thank you so much.
Konstantinos

Hi Joe, any luck with the example file? Please have a look at the latest comment I added (June 15th).
Best regards
Konstantinos

if you can post your email address I will send to you directly

konstantinos.kotzakoulakis@gmail.com

Got it thanks! So you need to specify all PISCES tracers in the croco.in file, even if some of them are not in the river flow (by setting the tracers to F). I think I understand better now. Thanks!

Hi Konstantinos, I’m having troubles wit rivers and pieces, can you share with me the portion of your croco.in where you input the river properties in psource_ncfile?
Alex

Hi Alex,

Depending which version of the Pisces model you have defines you have a specific number of bio_tracers that you have to add in your croco.in file and in the boundary and initial files. See the Pisces number of bio_tracers from the param.h file:

ifdef BIOLOGY

ifdef PISCES

ifdef key_pisces_quota

ifdef key_ligand

     parameter (ntrc_bio=40)

else

     parameter (ntrc_bio=39)

endif

else

ifdef key_ligand

     parameter (ntrc_bio=25)

else

     parameter (ntrc_bio=24)

endif

endif

In the simplest case (last one) you have 24 additional tracers on top of the T,S that you have to define.

If you give a constant value (not time dependent) based on your definition in the cppdefs.h file e.g.:
/* Point Sources - Rivers */

define PSOURCE

define PSOURCE_NCFILE

ifdef PSOURCE_NCFILE

undef PSOURCE_NCFILE_TS

endif

You can simply add the tracer values in the croco.in file like this:
psource_ncfile: Nsrc Isrc Jsrc Dsrc qbardir Lsrc Tsrc runoff file name
croco_runoff.nc
1
36 106 0 -1 T T F F T F T T T F F F F F F T F F F F F F F F T F 17.6 34.88 0.0 0.0 2000.0 0.0 25.4 384.7 915.0 0.0 0.0 0.0 0.0 0.0 0.0 0.006 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 40.6 0.0

If you define time varying river tracers e.g. # define PSOURCE_NCFILE_TS
then you need to supply the time varying values in the croco_runoff.nc for the tracers only that you have values and you call them +_src e.g. NO3_src

Konstantinos

Thank you!
I was able to run with psource_ncfile flag, but when I tried psource_ncfile_ts it didn’t work.
I will include the info of these tracers in the croco.in and see if that works.
Regards, Alex

@Alex just remember, that you still need to add the true/false switches in the croco.in file for which bio_tracers you have values in the croco_runoff.nc netCDF file. So you still need the following line (of course you change the true/false to what you have, and the values here are not used when PSOURCE_NCFILE_TS is defined):
36 106 0 -1 T T F F T F T T T F F F F F F T F F F F F F F F T F 17.6 34.88 0.0 0.0 2000.0 0.0 25.4 384.7 915.0 0.0 0.0 0.0 0.0 0.0 0.0 0.006 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 40.6 0.0

Also you need to have as many lines as your point sources, and the croco_runoff.nc will neen to have the same number of columns for each tracer as the number of your source points.
K.

Thank you, that makes sense now to me.