Scheduled Downtime
On Tuesday 24 October 2023 @ 5pm MT the forums will be in read only mode in preparation for the downtime. On Wednesday 25 October 2023 @ 5am MT, this website will be down for maintenance and expected to return online later in the morning.
Normal Operations
The forums are back online with normal operations. If you notice any issues or errors related to the forums, please reach out to help@ucar.edu

pbuf index initialization to be used in external module

nuvolet

Toni Viudez
Member
I made the changes you suggested and I got this message, which I think is related to the call in the nudging module:

Code:
       call nudging_timestep_init(phys_state, phys_tend, phys_buffer_chunk)
                                                                                       1
Error: Type mismatch in argument ‘pbuf’ at (1); passed TYPE(physics_tend) to TYPE(physics_buffer_desc)
gmake: *** [physpkg.o] Error 1

In the nudging module from previous suggestions you made I did this:

Code:
  !================================================================
!   subroutine nudging_timestep_init(phys_state)
  subroutine nudging_timestep_init(phys_state,pbuf)

Thanks

Toni
 

nuvolet

Toni Viudez
Member
OK I see the problem. modal_aero_sw need the 1D pbuf so you'll need to loop over the 2D pbuf.

You can try moving the call to nudging_timeste_init up into the end of this loop in physpkg.F90:


You'll also need to change pbuf2 back to pbuf inside the nudging module.

Courtney
I also have a question
Why here I need to use the phys_tend?. I do not use it in the nudging module for nudging_timestep_init.
And because in the loop for each chunk, should not be something like the previous calls in that loop:

Code:
!$OMP PARALLEL DO PRIVATE (C, NCOL, phys_buffer_chunk)

    do c=begchunk,endchunk
       ncol = get_ncols_p(c)
       phys_buffer_chunk => pbuf_get_chunk(pbuf2d, c)
       !
       ! surface diagnostics for history files
       !
       call t_startf('diag_surf')
       call diag_surf(cam_in(c), cam_out(c), phys_state(c), phys_buffer_chunk)
       call t_stopf('diag_surf')

       call tphysac(ztodt, cam_in(c),  &
            cam_out(c),                              &
            phys_state(c), phys_tend(c), phys_buffer_chunk)
       call nudging_timestep_init(phys_state(c), phys_tend(c), phys_buffer_chunk)           

    end do

Thanks in advance

Toni
 

nuvolet

Toni Viudez
Member
I also tried to use it but without phys_tend:

Code:
!$OMP PARALLEL DO PRIVATE (C, NCOL, phys_buffer_chunk)

    do c=begchunk,endchunk
       ncol = get_ncols_p(c)
       phys_buffer_chunk => pbuf_get_chunk(pbuf2d, c)
       !
       ! surface diagnostics for history files
       !
       call t_startf('diag_surf')
       call diag_surf(cam_in(c), cam_out(c), phys_state(c), phys_buffer_chunk)
       call t_stopf('diag_surf')

       call tphysac(ztodt, cam_in(c),  &
            cam_out(c),                              &
            phys_state(c), phys_tend(c), phys_buffer_chunk)
!        call nudging_timestep_init(phys_state, phys_tend, phys_buffer_chunk)           
       call nudging_timestep_init(phys_state(c), phys_buffer_chunk)           
    end do                    ! Chunk loop

And noe the error is from another module in the control:

Code:
    call phys_run2(phys_state, dtime_phys, phys_tend, pbuf2d,  cam_out, cam_in )
                                                                               1
Error: Missing actual argument for argument ‘state’ at (1)
gmake: *** [cam_comp.o] Error 1

Thanks

Toni
 

peverley

Courtney Peverley
Moderator
Staff member
Hi Toni,

Have you changed the calling list for phys_run2 in physpkg.F90? Can you post the full subroutine declaration for phys_run2? Mine looks like:

subroutine phys_run2(phys_state, ztodt, phys_tend, pbuf2d, cam_out, &
cam_in )

Thanks
Courtney
 

nuvolet

Toni Viudez
Member
Hi Courtney,

Originally in the physpkg.F90 looks like what you show:

Code:
   subroutine phys_run2(phys_state, ztodt, phys_tend, pbuf2d,  cam_out, &
        cam_in )

And when I ran the case with the pbuf use I do this:

Code:
   subroutine phys_run2(phys_state, ztodt, phys_tend, pbuf2d,  cam_out, &
        cam_in, state,tend,pbuf )

Thanks

Toni
 

peverley

Courtney Peverley
Moderator
Staff member
Ok.

Can you try removing those three variables (state, tend, pbuf) from the subroutine declaration? You already have those variables but they have different names (phys_state, phys_tend, pbuf2d).

Court
 

nuvolet

Toni Viudez
Member
Ok.

Can you try removing those three variables (state, tend, pbuf) from the subroutine declaration? You already have those variables but they have different names (phys_state, phys_tend, pbuf2d).

Court
I removed those variables (state,tend,pbuf) and still get an error, I think because how is defined nudging_timestep_init in the nudging.F90 subroutine:

Code:
call nudging_timestep_init(phys_state, phys_tend, phys_buffer_chunk)
                                                                                       1
Error: Type mismatch in argument ‘pbuf’ at (1); passed TYPE(physics_tend) to TYPE(physics_buffer_desc)
gmake: *** [physpkg.o] Error 1

Thanks in advance

Toni
 

peverley

Courtney Peverley
Moderator
Staff member
Hi Toni,

In your nudging_timestep_init calling list, you should have

type(physics_buffer_desc),pointer, dimension(:) :: phys_buffer_chunk

(rather than dimension(:,:))

Is this what you currently have? If not, can you send me the full calling list (all input/output variables) for this routine?

Court
 

nuvolet

Toni Viudez
Member
Hi Toni,

In your nudging_timestep_init calling list, you should have

type(physics_buffer_desc),pointer, dimension(:) :: phys_buffer_chunk

(rather than dimension(:,:))

Is this what you currently have? If not, can you send me the full calling list (all input/output variables) for this routine?

Court
Hi Courtney,

I have what you indicated for physical_buffer_chunk

Enclosed you can see the physpkg I have been modifying, following all your suggestions.

Thanks
 

Attachments

  • physpkg_modified_Jan-04.txt
    113.2 KB · Views: 4

peverley

Courtney Peverley
Moderator
Staff member
Hi Toni,

Can you send along what you have for nudging.F90 as well?

Thanks!
Courtney
 

nuvolet

Toni Viudez
Member
Hi Courtney,

Here it is a version of the one I am using to call the module modal_aer_opt.F90 into the nudging module in order to have and use output variables 'tauxar', 'wa', 'ga', 'fa.

Thanks

Toni
 

Attachments

  • nudging-Dec-14-call-modal-aer-sw.txt
    160.9 KB · Views: 3

peverley

Courtney Peverley
Moderator
Staff member
Thanks Toni,

I see you have several different subroutine definitions (some commented out). This is the current uncommented one that you have in the text file you just sent:
subroutine nudging_timestep_tend(phys_state,phys_tend)
This does not include the physics buffer. I'm guessing you want to end up using this one:
subroutine nudging_timestep_init(phys_state,phys_tend,pbuf)
So you'll want to uncomment that one and make sure your argument list looks like this:
! Arguments
!-----------
type(physics_state),intent(in):: phys_state(begchunk:endchunk)
! --- 01/05/23
type(physics_tend ), intent(inout), dimension(begchunk:endchunk) :: phys_tend
type(physics_buffer_desc), pointer :: pbuf(:)

(and you'll want to remove the bolded line above from later in your routine).

You'll also need to add this bolded use statement:
use cam_control_mod, only: eccen, mvelpp, lambm0, obliqr
use physics_buffer, only: physics_buffer_desc

Once all that is in place, you should (hopefully) be able to call
call nudging_timestep_init(phys_state, phys_tend, phys_buffer_chunk)
from physpkg.F90

Let me know if you have any questions.

Courtney
 

nuvolet

Toni Viudez
Member
Hi Courtney,

I made the changes you suggested (only in the nudging module and the physpkg).
Now I do not have errors about the pbuf, but still having something here in the nudging module:

Code:
type(physics_tend), intent(inout), dimension(begchunk:endchunk) :: phys_tend
                     1
Error: Derived type ‘physics_tend’ at (1) is being used before it is defined

and

Code:
subroutine nudging_timestep_init(phys_state,phys_tend,pbuf)
                                                       1
Error: Symbol ‘phys_tend’ at (1) has no IMPLICIT type; did you mean ‘phys_state’?

Thanks in advance for you help

Toni
 

peverley

Courtney Peverley
Moderator
Staff member
Ah, oops. Yes you'll need to also add this use statement to your nudging_timestep_init routine:

use physics_types, only: physics_tend

Hope that works!
Courtney
 

nuvolet

Toni Viudez
Member
Hi Courtney,

This helped but still getting some errors.

First after adding that line was that physpkg was missing phy_tend at the end of the module when we are updating the nudging values:

Code:
  ! Update Nudging values, if needed
  !----------------------------------

  if(Nudge_Model) call nudging_timestep_init(phys_state)

Therefore I added it as:

Code:
  ! Update Nudging values, if needed
  !----------------------------------

   if(Nudge_Model) call nudging_timestep_init(phys_state,phys_tend)

Next, after attempting to create this case, it was necessary to define physical_tend in that subroutine (physical_timestep_init) as:

Code:
use physics_types, only: physics_tend
....
type(physics_tend), pointer       :: phys_tend(:)

Then, when I tried to compile that case I got this message:

Code:
if(Nudge_Model) call nudging_timestep_init(phys_state,phys_tend)
                                                                  1
Error: Missing actual argument for argument ‘pbuf’ at (1)
gmake: *** [physpkg.o] Error 1

Which, how we have defined nudging_timestep_init in subroutine phys_run2(phys_state, ztodt, phys_tend, pbuf2d, cam_out, cam_in ), I guessed I should had in phys_timestep_init these lines:

Code:
  use physics_buffer,  only: physics_buffer_desc
  ....
  type(physics_buffer_desc),pointer, dimension(:)     :: phys_buffer_chunk
  ....
  ....
  if(Nudge_Model) call nudging_timestep_init(phys_state,phys_tend,phys_buffer_chunk)

Finally, when I run that case I got this message which I have to look in the cesm.log file:

Code:
....

 ERROR: GET_PBUF1D_FIELD_BY_INDEX: index (125) out of range
 ERROR: GET_PBUF1D_FIELD_BY_INDEX: index (125) out of range
 ERROR: GET_PBUF1D_FIELD_BY_INDEX: index (125) out of range
 ERROR: GET_PBUF1D_FIELD_BY_INDEX: index (125) out of range
 ERROR: GET_PBUF1D_FIELD_BY_INDEX: index (125) out of range
 ERROR: GET_PBUF1D_FIELD_BY_INDEX: index (125) out of range
 ERROR: GET_PBUF1D_FIELD_BY_INDEX: index (125) out of range

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
 ERROR: GET_PBUF1D_FIELD_BY_INDEX: index (125) out of range

....


I hope these steps I took can give you an idea where I am right now.

Thanks again for your help.

Toni
 

peverley

Courtney Peverley
Moderator
Staff member
Hi Toni,

Can you post the following files as they currently are (I know you previously posted some of these but I want to see the current state):

physpkg.F90
nudging.F90
The full cesm.log file from your case
The full atm.log file from your case.

Thanks!
Courtney
 

nuvolet

Toni Viudez
Member
Hi Courtney!!

Yes, here they're.
Obviously the name are the version I am keeping and modifying before I change it and mode to /SourceMods/src.cam/

Thanks in advance.
 

Attachments

  • nudging-Dec-14-call-modal-aero-sw-3.txt
    170.3 KB · Views: 2
  • physpkg_modified_Jan-04.txt
    113.5 KB · Views: 2
  • cesm.log.230119-225212.txt
    84.6 KB · Views: 5
  • atm.log.230119-225212.txt
    1,013.1 KB · Views: 2

peverley

Courtney Peverley
Moderator
Staff member
Hi again Toni,

A couple things to try since I can't tell where there error is coming from without a full traceback.

1. Are you running in debug mode? You can check by running "./xmlquery DEBUG" - if FALSE is returned, run "./xmlchange DEBUG=TRUE"

2. Try switching compilers. I'm not sure what compiler you're currently using (if you run "./xmlquery COMPILER" you should get the current compiler), but switching that up can sometimes yield additional information about an error.

3. If none of that works (rebuilding and rerunning the case after making those changes), can you send me the results of these commands (from the base $CAM directory):
# git diff src/physics/cam/nudging.F90
# git diff src/physics/cam/physpkg.F90
# git status

Thanks!
Courtney
 

nuvolet

Toni Viudez
Member
Hi again Toni,

A couple things to try since I can't tell where there error is coming from without a full traceback.

1. Are you running in debug mode? You can check by running "./xmlquery DEBUG" - if FALSE is returned, run "./xmlchange DEBUG=TRUE"

2. Try switching compilers. I'm not sure what compiler you're currently using (if you run "./xmlquery COMPILER" you should get the current compiler), but switching that up can sometimes yield additional information about an error.

3. If none of that works (rebuilding and rerunning the case after making those changes), can you send me the results of these commands (from the base $CAM directory):
# git diff src/physics/cam/nudging.F90
# git diff src/physics/cam/physpkg.F90
# git status

Thanks!
Courtney
Hi Courtney,

About your first question I am not running in debug mode, so I guess I will start using that option.
Regarding the compiler, using the command you suggested, I am using gnu, which is by default in our cluster. I do not know if I can change the compiler.
Regarding the last request, I do not understand what do you mean by running those commands. From the base $CAM directory, do you mean from: .../components/cam/src/physics/cam?

On the other hand, I was wondering if there is another way to make ll this easier?. I thought that by using the module modal_aer_opt.F90 in the nudging.F90 I am working, it would be pretty straight forward to get the out puts of the subroutine modal_aero_sw.

Something like that:

Code:
...
use modal_aer_opt ,only: modal_aero_sw
...
...
call modal_aer_sw(list_idx, state, pbuf, nnite, idxnite,tauxar, wa, ga, fa)
...

Additionally, by adding the lines for having those aerosols optical properties in the history files (see enclosed file). I can have those, which means that, I think, that are computed each time I create a case and I only want to pass them into the nudging module.

Thanks in advance for the time taking a look to I am doing.

Toni
 

Attachments

  • modal_aer_opt_hfiles.txt
    74.4 KB · Views: 1

peverley

Courtney Peverley
Moderator
Staff member
Hi Toni, you can run those commands from anywhere inside the .../components/cam directory.

I'm not quite sure I understand exactly what you're doing. Can you clarify what exactly you want to do with the variables tauxar, wa, ga, fa ?

Courtney
 
Top