initialize_geopotential_model Function

private function initialize_geopotential_model(itype, gravfile, n, m) result(cp) bind(c,name='initialize_geopotential_model')

Note

This is just a wapper for initialize in geopotential_model.

mueller method

Arguments

Type IntentOptional Attributes Name
integer(kind=c_int), intent(in), value :: itype

mode :

  • 1 (Mueller) is only mode currently supported
type(c_ptr), intent(in), value :: gravfile

gravity coefficient file name

integer(kind=c_int), intent(in), value :: n

degree

integer(kind=c_int), intent(in), value :: m

order

Return Value type(c_ptr)

pointer to a container containing a geopotential_model


Calls

proc~~initialize_geopotential_model~~CallsGraph proc~initialize_geopotential_model c_interface_module::initialize_geopotential_model destroy destroy proc~initialize_geopotential_model->destroy initialize initialize proc~initialize_geopotential_model->initialize proc~c_ptr_to_f_string c_interface_module::c_ptr_to_f_string proc~initialize_geopotential_model->proc~c_ptr_to_f_string interface~strlen c_interface_module::strlen proc~c_ptr_to_f_string->interface~strlen s s proc~c_ptr_to_f_string->s

Source Code

    function initialize_geopotential_model(itype,gravfile,n,m) &
        result(cp) bind(c,name='initialize_geopotential_model')

    implicit none

    integer(c_int),intent(in),value :: itype  !! mode :
                                              !!
                                              !! * 1 (Mueller) is only mode
                                              !! currently supported
    type(c_ptr),intent(in),value :: gravfile !! gravity coefficient file name
    integer(c_int),intent(in),value :: n    !! degree
    integer(c_int),intent(in),value :: m    !! order
    type(c_ptr) :: cp   !! pointer to a [[container]]
                        !! containing a [[geopotential_model]]

    type(container),pointer :: grav_container  !! Fortran version of `cp`
    class(geopotential_model),pointer :: grav  !! the data in the container
    logical :: status_ok !! initialization status flag
    character(len=:),allocatable :: gravfile_f  !! Fortran version of `gravfile`

    allocate(grav_container)

    select case (itype)
    case(1) !! mueller method
        allocate(geopotential_model_mueller :: grav_container%data)
        select type (g => grav_container%data)
        class is (geopotential_model_mueller)

            ! get the gravity file name:
            call c_ptr_to_f_string(gravfile,gravfile_f)

            call g%initialize(gravfile_f,n,m,status_ok)
            if (.not. status_ok) then
                write(*,*) 'error in initialize!'
                call g%destroy()
                cp = c_null_ptr
            else
                cp = c_loc(grav_container)
            end if

        end select

    case default
        error stop 'error: invalid itype input'
    end select

    ! if there was an error:
    if (c_associated(cp,c_null_ptr)) then
        deallocate(grav_container)
    end if

    end function initialize_geopotential_model