Connect to CDB#

See also

Visual Basic for Applications - Examples

Problem Description#

To connect to the CDB, the project must be configured (see Fortran). The example bellow shows how to connect to the CDB.

Problem Solution#

An example can be found by following:

C:\<sofistik_installation>\2024\SOFiSTiK 2024\interfaces\examples\fortran\connect_to_cdb
Connect to CDB example#
program connect_to_CDB
implicit none

! Variables
integer :: nid, l, ie, index, istat
character(len=30)   :: filename
character(len=72)   :: text

index = 99
! input here the CDB name or the CDB path
filename = "S:\test\connect_to_cdb.cdb"

! Connect to CDB
! In this example 64bit debug DLL is used
call cdinit(filename, index)
if (nid > 0) then
    write(*,*) "  cdb_init of ", filename," succesfull ", nid
else
    write(*,*) "  cdb_init of ", filename," not succesfull ", nid
endif

! Check status
call cdstat(index, istat)
print *, "CDB status is: ", istat

! Lets close the CDB now
call cdclose(0)

! Check status again, if closed, status = 0
call cdstat(index, istat)
print *, "CDB status is: ", istat

! Press <ENTER> key to close the program
print *, "Press <ENTER> key to close the program"
read (*,*)

end program connect_to_CDB

Please modify the .CDB path in the code. If the .CDB file does not exist it will be created, because of the cdbIndex=99 value (for more details please read CDBASE.CHM).

filename = "connect_to_cdb.cdb"

The interfaces example folder contains:

  • connect_to_CDB.Solution

  • connect_to_CDB (folder)

  • connect_to_CDB/connect_to_CDB.f90

  • connect_to_CDB/connect_to_CDB.vfproj